documentation.d.ts 3.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706
  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 the capacity of the manager
  10956. */
  10957. get capacity(): number;
  10958. /**
  10959. * Gets or sets the spritesheet texture
  10960. */
  10961. get texture(): Texture;
  10962. set texture(value: Texture);
  10963. private _blendMode;
  10964. /**
  10965. * Blend mode use to render the particle, it can be any of
  10966. * the static Constants.ALPHA_x properties provided in this class.
  10967. * Default value is Constants.ALPHA_COMBINE
  10968. */
  10969. get blendMode(): number;
  10970. set blendMode(blendMode: number);
  10971. /** Disables writing to the depth buffer when rendering the sprites.
  10972. * It can be handy to disable depth writing when using textures without alpha channel
  10973. * and setting some specific blend modes.
  10974. */
  10975. disableDepthWrite: boolean;
  10976. /**
  10977. * Creates a new sprite manager
  10978. * @param name defines the manager's name
  10979. * @param imgUrl defines the sprite sheet url
  10980. * @param capacity defines the maximum allowed number of sprites
  10981. * @param cellSize defines the size of a sprite cell
  10982. * @param scene defines the hosting scene
  10983. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10984. * @param samplingMode defines the smapling mode to use with spritesheet
  10985. * @param fromPacked set to false; do not alter
  10986. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10987. */
  10988. constructor(
  10989. /** defines the manager's name */
  10990. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10991. /**
  10992. * Returns the string "SpriteManager"
  10993. * @returns "SpriteManager"
  10994. */
  10995. getClassName(): string;
  10996. private _makePacked;
  10997. private _appendSpriteVertex;
  10998. private _checkTextureAlpha;
  10999. /**
  11000. * Intersects the sprites with a ray
  11001. * @param ray defines the ray to intersect with
  11002. * @param camera defines the current active camera
  11003. * @param predicate defines a predicate used to select candidate sprites
  11004. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11005. * @returns null if no hit or a PickingInfo
  11006. */
  11007. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11008. /**
  11009. * Intersects the sprites with a ray
  11010. * @param ray defines the ray to intersect with
  11011. * @param camera defines the current active camera
  11012. * @param predicate defines a predicate used to select candidate sprites
  11013. * @returns null if no hit or a PickingInfo array
  11014. */
  11015. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11016. /**
  11017. * Render all child sprites
  11018. */
  11019. render(): void;
  11020. /**
  11021. * Release associated resources
  11022. */
  11023. dispose(): void;
  11024. }
  11025. }
  11026. declare module BABYLON {
  11027. /** Interface used by value gradients (color, factor, ...) */
  11028. export interface IValueGradient {
  11029. /**
  11030. * Gets or sets the gradient value (between 0 and 1)
  11031. */
  11032. gradient: number;
  11033. }
  11034. /** Class used to store color4 gradient */
  11035. export class ColorGradient implements IValueGradient {
  11036. /**
  11037. * Gets or sets the gradient value (between 0 and 1)
  11038. */
  11039. gradient: number;
  11040. /**
  11041. * Gets or sets first associated color
  11042. */
  11043. color1: Color4;
  11044. /**
  11045. * Gets or sets second associated color
  11046. */
  11047. color2?: Color4 | undefined;
  11048. /**
  11049. * Creates a new color4 gradient
  11050. * @param gradient gets or sets the gradient value (between 0 and 1)
  11051. * @param color1 gets or sets first associated color
  11052. * @param color2 gets or sets first second color
  11053. */
  11054. constructor(
  11055. /**
  11056. * Gets or sets the gradient value (between 0 and 1)
  11057. */
  11058. gradient: number,
  11059. /**
  11060. * Gets or sets first associated color
  11061. */
  11062. color1: Color4,
  11063. /**
  11064. * Gets or sets second associated color
  11065. */
  11066. color2?: Color4 | undefined);
  11067. /**
  11068. * Will get a color picked randomly between color1 and color2.
  11069. * If color2 is undefined then color1 will be used
  11070. * @param result defines the target Color4 to store the result in
  11071. */
  11072. getColorToRef(result: Color4): void;
  11073. }
  11074. /** Class used to store color 3 gradient */
  11075. export class Color3Gradient implements IValueGradient {
  11076. /**
  11077. * Gets or sets the gradient value (between 0 and 1)
  11078. */
  11079. gradient: number;
  11080. /**
  11081. * Gets or sets the associated color
  11082. */
  11083. color: Color3;
  11084. /**
  11085. * Creates a new color3 gradient
  11086. * @param gradient gets or sets the gradient value (between 0 and 1)
  11087. * @param color gets or sets associated color
  11088. */
  11089. constructor(
  11090. /**
  11091. * Gets or sets the gradient value (between 0 and 1)
  11092. */
  11093. gradient: number,
  11094. /**
  11095. * Gets or sets the associated color
  11096. */
  11097. color: Color3);
  11098. }
  11099. /** Class used to store factor gradient */
  11100. export class FactorGradient implements IValueGradient {
  11101. /**
  11102. * Gets or sets the gradient value (between 0 and 1)
  11103. */
  11104. gradient: number;
  11105. /**
  11106. * Gets or sets first associated factor
  11107. */
  11108. factor1: number;
  11109. /**
  11110. * Gets or sets second associated factor
  11111. */
  11112. factor2?: number | undefined;
  11113. /**
  11114. * Creates a new factor gradient
  11115. * @param gradient gets or sets the gradient value (between 0 and 1)
  11116. * @param factor1 gets or sets first associated factor
  11117. * @param factor2 gets or sets second associated factor
  11118. */
  11119. constructor(
  11120. /**
  11121. * Gets or sets the gradient value (between 0 and 1)
  11122. */
  11123. gradient: number,
  11124. /**
  11125. * Gets or sets first associated factor
  11126. */
  11127. factor1: number,
  11128. /**
  11129. * Gets or sets second associated factor
  11130. */
  11131. factor2?: number | undefined);
  11132. /**
  11133. * Will get a number picked randomly between factor1 and factor2.
  11134. * If factor2 is undefined then factor1 will be used
  11135. * @returns the picked number
  11136. */
  11137. getFactor(): number;
  11138. }
  11139. /**
  11140. * Helper used to simplify some generic gradient tasks
  11141. */
  11142. export class GradientHelper {
  11143. /**
  11144. * Gets the current gradient from an array of IValueGradient
  11145. * @param ratio defines the current ratio to get
  11146. * @param gradients defines the array of IValueGradient
  11147. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11148. */
  11149. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11150. }
  11151. }
  11152. declare module BABYLON {
  11153. interface ThinEngine {
  11154. /**
  11155. * Creates a dynamic texture
  11156. * @param width defines the width of the texture
  11157. * @param height defines the height of the texture
  11158. * @param generateMipMaps defines if the engine should generate the mip levels
  11159. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11160. * @returns the dynamic texture inside an InternalTexture
  11161. */
  11162. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  11163. /**
  11164. * Update the content of a dynamic texture
  11165. * @param texture defines the texture to update
  11166. * @param canvas defines the canvas containing the source
  11167. * @param invertY defines if data must be stored with Y axis inverted
  11168. * @param premulAlpha defines if alpha is stored as premultiplied
  11169. * @param format defines the format of the data
  11170. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  11171. */
  11172. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  11173. }
  11174. }
  11175. declare module BABYLON {
  11176. /**
  11177. * Helper class used to generate a canvas to manipulate images
  11178. */
  11179. export class CanvasGenerator {
  11180. /**
  11181. * Create a new canvas (or offscreen canvas depending on the context)
  11182. * @param width defines the expected width
  11183. * @param height defines the expected height
  11184. * @return a new canvas or offscreen canvas
  11185. */
  11186. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  11187. }
  11188. }
  11189. declare module BABYLON {
  11190. /**
  11191. * A class extending Texture allowing drawing on a texture
  11192. * @see http://doc.babylonjs.com/how_to/dynamictexture
  11193. */
  11194. export class DynamicTexture extends Texture {
  11195. private _generateMipMaps;
  11196. private _canvas;
  11197. private _context;
  11198. /**
  11199. * Creates a DynamicTexture
  11200. * @param name defines the name of the texture
  11201. * @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
  11202. * @param scene defines the scene where you want the texture
  11203. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  11204. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  11205. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  11206. */
  11207. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  11208. /**
  11209. * Get the current class name of the texture useful for serialization or dynamic coding.
  11210. * @returns "DynamicTexture"
  11211. */
  11212. getClassName(): string;
  11213. /**
  11214. * Gets the current state of canRescale
  11215. */
  11216. get canRescale(): boolean;
  11217. private _recreate;
  11218. /**
  11219. * Scales the texture
  11220. * @param ratio the scale factor to apply to both width and height
  11221. */
  11222. scale(ratio: number): void;
  11223. /**
  11224. * Resizes the texture
  11225. * @param width the new width
  11226. * @param height the new height
  11227. */
  11228. scaleTo(width: number, height: number): void;
  11229. /**
  11230. * Gets the context of the canvas used by the texture
  11231. * @returns the canvas context of the dynamic texture
  11232. */
  11233. getContext(): CanvasRenderingContext2D;
  11234. /**
  11235. * Clears the texture
  11236. */
  11237. clear(): void;
  11238. /**
  11239. * Updates the texture
  11240. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11241. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  11242. */
  11243. update(invertY?: boolean, premulAlpha?: boolean): void;
  11244. /**
  11245. * Draws text onto the texture
  11246. * @param text defines the text to be drawn
  11247. * @param x defines the placement of the text from the left
  11248. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  11249. * @param font defines the font to be used with font-style, font-size, font-name
  11250. * @param color defines the color used for the text
  11251. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  11252. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11253. * @param update defines whether texture is immediately update (default is true)
  11254. */
  11255. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  11256. /**
  11257. * Clones the texture
  11258. * @returns the clone of the texture.
  11259. */
  11260. clone(): DynamicTexture;
  11261. /**
  11262. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  11263. * @returns a serialized dynamic texture object
  11264. */
  11265. serialize(): any;
  11266. /** @hidden */
  11267. _rebuild(): void;
  11268. }
  11269. }
  11270. declare module BABYLON {
  11271. interface ThinEngine {
  11272. /**
  11273. * Creates a raw texture
  11274. * @param data defines the data to store in the texture
  11275. * @param width defines the width of the texture
  11276. * @param height defines the height of the texture
  11277. * @param format defines the format of the data
  11278. * @param generateMipMaps defines if the engine should generate the mip levels
  11279. * @param invertY defines if data must be stored with Y axis inverted
  11280. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11281. * @param compression defines the compression used (null by default)
  11282. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11283. * @returns the raw texture inside an InternalTexture
  11284. */
  11285. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11286. /**
  11287. * Update a raw texture
  11288. * @param texture defines the texture to update
  11289. * @param data defines the data to store in the texture
  11290. * @param format defines the format of the data
  11291. * @param invertY defines if data must be stored with Y axis inverted
  11292. */
  11293. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11294. /**
  11295. * Update a raw texture
  11296. * @param texture defines the texture to update
  11297. * @param data defines the data to store in the texture
  11298. * @param format defines the format of the data
  11299. * @param invertY defines if data must be stored with Y axis inverted
  11300. * @param compression defines the compression used (null by default)
  11301. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11302. */
  11303. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11304. /**
  11305. * Creates a new raw cube texture
  11306. * @param data defines the array of data to use to create each face
  11307. * @param size defines the size of the textures
  11308. * @param format defines the format of the data
  11309. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11310. * @param generateMipMaps defines if the engine should generate the mip levels
  11311. * @param invertY defines if data must be stored with Y axis inverted
  11312. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11313. * @param compression defines the compression used (null by default)
  11314. * @returns the cube texture as an InternalTexture
  11315. */
  11316. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11317. /**
  11318. * Update a raw cube texture
  11319. * @param texture defines the texture to udpdate
  11320. * @param data defines the data to store
  11321. * @param format defines the data format
  11322. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11323. * @param invertY defines if data must be stored with Y axis inverted
  11324. */
  11325. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11326. /**
  11327. * Update a raw cube texture
  11328. * @param texture defines the texture to udpdate
  11329. * @param data defines the data to store
  11330. * @param format defines the data format
  11331. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11332. * @param invertY defines if data must be stored with Y axis inverted
  11333. * @param compression defines the compression used (null by default)
  11334. */
  11335. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11336. /**
  11337. * Update a raw cube texture
  11338. * @param texture defines the texture to udpdate
  11339. * @param data defines the data to store
  11340. * @param format defines the data format
  11341. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11342. * @param invertY defines if data must be stored with Y axis inverted
  11343. * @param compression defines the compression used (null by default)
  11344. * @param level defines which level of the texture to update
  11345. */
  11346. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11347. /**
  11348. * Creates a new raw cube texture from a specified url
  11349. * @param url defines the url where the data is located
  11350. * @param scene defines the current scene
  11351. * @param size defines the size of the textures
  11352. * @param format defines the format of the data
  11353. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11354. * @param noMipmap defines if the engine should avoid generating the mip levels
  11355. * @param callback defines a callback used to extract texture data from loaded data
  11356. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11357. * @param onLoad defines a callback called when texture is loaded
  11358. * @param onError defines a callback called if there is an error
  11359. * @returns the cube texture as an InternalTexture
  11360. */
  11361. 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;
  11362. /**
  11363. * Creates a new raw cube texture from a specified url
  11364. * @param url defines the url where the data is located
  11365. * @param scene defines the current scene
  11366. * @param size defines the size of the textures
  11367. * @param format defines the format of the data
  11368. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11369. * @param noMipmap defines if the engine should avoid generating the mip levels
  11370. * @param callback defines a callback used to extract texture data from loaded data
  11371. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11372. * @param onLoad defines a callback called when texture is loaded
  11373. * @param onError defines a callback called if there is an error
  11374. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11375. * @param invertY defines if data must be stored with Y axis inverted
  11376. * @returns the cube texture as an InternalTexture
  11377. */
  11378. 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;
  11379. /**
  11380. * Creates a new raw 3D texture
  11381. * @param data defines the data used to create the texture
  11382. * @param width defines the width of the texture
  11383. * @param height defines the height of the texture
  11384. * @param depth defines the depth of the texture
  11385. * @param format defines the format of the texture
  11386. * @param generateMipMaps defines if the engine must generate mip levels
  11387. * @param invertY defines if data must be stored with Y axis inverted
  11388. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11389. * @param compression defines the compressed used (can be null)
  11390. * @param textureType defines the compressed used (can be null)
  11391. * @returns a new raw 3D texture (stored in an InternalTexture)
  11392. */
  11393. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11394. /**
  11395. * Update a raw 3D texture
  11396. * @param texture defines the texture to update
  11397. * @param data defines the data to store
  11398. * @param format defines the data format
  11399. * @param invertY defines if data must be stored with Y axis inverted
  11400. */
  11401. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11402. /**
  11403. * Update a raw 3D texture
  11404. * @param texture defines the texture to update
  11405. * @param data defines the data to store
  11406. * @param format defines the data format
  11407. * @param invertY defines if data must be stored with Y axis inverted
  11408. * @param compression defines the used compression (can be null)
  11409. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11410. */
  11411. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11412. /**
  11413. * Creates a new raw 2D array texture
  11414. * @param data defines the data used to create the texture
  11415. * @param width defines the width of the texture
  11416. * @param height defines the height of the texture
  11417. * @param depth defines the number of layers of the texture
  11418. * @param format defines the format of the texture
  11419. * @param generateMipMaps defines if the engine must generate mip levels
  11420. * @param invertY defines if data must be stored with Y axis inverted
  11421. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11422. * @param compression defines the compressed used (can be null)
  11423. * @param textureType defines the compressed used (can be null)
  11424. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11425. */
  11426. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11427. /**
  11428. * Update a raw 2D array texture
  11429. * @param texture defines the texture to update
  11430. * @param data defines the data to store
  11431. * @param format defines the data format
  11432. * @param invertY defines if data must be stored with Y axis inverted
  11433. */
  11434. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11435. /**
  11436. * Update a raw 2D array texture
  11437. * @param texture defines the texture to update
  11438. * @param data defines the data to store
  11439. * @param format defines the data format
  11440. * @param invertY defines if data must be stored with Y axis inverted
  11441. * @param compression defines the used compression (can be null)
  11442. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11443. */
  11444. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11445. }
  11446. }
  11447. declare module BABYLON {
  11448. /**
  11449. * Raw texture can help creating a texture directly from an array of data.
  11450. * This can be super useful if you either get the data from an uncompressed source or
  11451. * if you wish to create your texture pixel by pixel.
  11452. */
  11453. export class RawTexture extends Texture {
  11454. /**
  11455. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11456. */
  11457. format: number;
  11458. /**
  11459. * Instantiates a new RawTexture.
  11460. * Raw texture can help creating a texture directly from an array of data.
  11461. * This can be super useful if you either get the data from an uncompressed source or
  11462. * if you wish to create your texture pixel by pixel.
  11463. * @param data define the array of data to use to create the texture
  11464. * @param width define the width of the texture
  11465. * @param height define the height of the texture
  11466. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11467. * @param scene define the scene the texture belongs to
  11468. * @param generateMipMaps define whether mip maps should be generated or not
  11469. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11470. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11471. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11472. */
  11473. constructor(data: ArrayBufferView, width: number, height: number,
  11474. /**
  11475. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11476. */
  11477. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11478. /**
  11479. * Updates the texture underlying data.
  11480. * @param data Define the new data of the texture
  11481. */
  11482. update(data: ArrayBufferView): void;
  11483. /**
  11484. * Creates a luminance texture from some data.
  11485. * @param data Define the texture data
  11486. * @param width Define the width of the texture
  11487. * @param height Define the height of the texture
  11488. * @param scene Define the scene the texture belongs to
  11489. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11490. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11491. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11492. * @returns the luminance texture
  11493. */
  11494. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11495. /**
  11496. * Creates a luminance alpha texture from some data.
  11497. * @param data Define the texture data
  11498. * @param width Define the width of the texture
  11499. * @param height Define the height of the texture
  11500. * @param scene Define the scene the texture belongs to
  11501. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11502. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11503. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11504. * @returns the luminance alpha texture
  11505. */
  11506. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11507. /**
  11508. * Creates an alpha texture from some data.
  11509. * @param data Define the texture data
  11510. * @param width Define the width of the texture
  11511. * @param height Define the height of the texture
  11512. * @param scene Define the scene the texture belongs to
  11513. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11514. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11515. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11516. * @returns the alpha texture
  11517. */
  11518. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11519. /**
  11520. * Creates a RGB texture from some data.
  11521. * @param data Define the texture data
  11522. * @param width Define the width of the texture
  11523. * @param height Define the height of the texture
  11524. * @param scene Define the scene the texture belongs to
  11525. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11526. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11527. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11528. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11529. * @returns the RGB alpha texture
  11530. */
  11531. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11532. /**
  11533. * Creates a RGBA texture from some data.
  11534. * @param data Define the texture data
  11535. * @param width Define the width of the texture
  11536. * @param height Define the height of the texture
  11537. * @param scene Define the scene the texture belongs to
  11538. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11539. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11540. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11541. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11542. * @returns the RGBA texture
  11543. */
  11544. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11545. /**
  11546. * Creates a R texture from some data.
  11547. * @param data Define the texture data
  11548. * @param width Define the width of the texture
  11549. * @param height Define the height of the texture
  11550. * @param scene Define the scene the texture belongs to
  11551. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11552. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11553. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11554. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11555. * @returns the R texture
  11556. */
  11557. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11558. }
  11559. }
  11560. declare module BABYLON {
  11561. interface AbstractScene {
  11562. /**
  11563. * The list of procedural textures added to the scene
  11564. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11565. */
  11566. proceduralTextures: Array<ProceduralTexture>;
  11567. }
  11568. /**
  11569. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11570. * in a given scene.
  11571. */
  11572. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11573. /**
  11574. * The component name helpfull to identify the component in the list of scene components.
  11575. */
  11576. readonly name: string;
  11577. /**
  11578. * The scene the component belongs to.
  11579. */
  11580. scene: Scene;
  11581. /**
  11582. * Creates a new instance of the component for the given scene
  11583. * @param scene Defines the scene to register the component in
  11584. */
  11585. constructor(scene: Scene);
  11586. /**
  11587. * Registers the component in a given scene
  11588. */
  11589. register(): void;
  11590. /**
  11591. * Rebuilds the elements related to this component in case of
  11592. * context lost for instance.
  11593. */
  11594. rebuild(): void;
  11595. /**
  11596. * Disposes the component and the associated ressources.
  11597. */
  11598. dispose(): void;
  11599. private _beforeClear;
  11600. }
  11601. }
  11602. declare module BABYLON {
  11603. interface ThinEngine {
  11604. /**
  11605. * Creates a new render target cube texture
  11606. * @param size defines the size of the texture
  11607. * @param options defines the options used to create the texture
  11608. * @returns a new render target cube texture stored in an InternalTexture
  11609. */
  11610. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11611. }
  11612. }
  11613. declare module BABYLON {
  11614. /** @hidden */
  11615. export var proceduralVertexShader: {
  11616. name: string;
  11617. shader: string;
  11618. };
  11619. }
  11620. declare module BABYLON {
  11621. /**
  11622. * 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.
  11623. * This is the base class of any Procedural texture and contains most of the shareable code.
  11624. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11625. */
  11626. export class ProceduralTexture extends Texture {
  11627. isCube: boolean;
  11628. /**
  11629. * Define if the texture is enabled or not (disabled texture will not render)
  11630. */
  11631. isEnabled: boolean;
  11632. /**
  11633. * Define if the texture must be cleared before rendering (default is true)
  11634. */
  11635. autoClear: boolean;
  11636. /**
  11637. * Callback called when the texture is generated
  11638. */
  11639. onGenerated: () => void;
  11640. /**
  11641. * Event raised when the texture is generated
  11642. */
  11643. onGeneratedObservable: Observable<ProceduralTexture>;
  11644. /** @hidden */
  11645. _generateMipMaps: boolean;
  11646. /** @hidden **/
  11647. _effect: Effect;
  11648. /** @hidden */
  11649. _textures: {
  11650. [key: string]: Texture;
  11651. };
  11652. /** @hidden */
  11653. protected _fallbackTexture: Nullable<Texture>;
  11654. private _size;
  11655. private _currentRefreshId;
  11656. private _frameId;
  11657. private _refreshRate;
  11658. private _vertexBuffers;
  11659. private _indexBuffer;
  11660. private _uniforms;
  11661. private _samplers;
  11662. private _fragment;
  11663. private _floats;
  11664. private _ints;
  11665. private _floatsArrays;
  11666. private _colors3;
  11667. private _colors4;
  11668. private _vectors2;
  11669. private _vectors3;
  11670. private _matrices;
  11671. private _fallbackTextureUsed;
  11672. private _fullEngine;
  11673. private _cachedDefines;
  11674. private _contentUpdateId;
  11675. private _contentData;
  11676. /**
  11677. * Instantiates a new procedural texture.
  11678. * 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.
  11679. * This is the base class of any Procedural texture and contains most of the shareable code.
  11680. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11681. * @param name Define the name of the texture
  11682. * @param size Define the size of the texture to create
  11683. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11684. * @param scene Define the scene the texture belongs to
  11685. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11686. * @param generateMipMaps Define if the texture should creates mip maps or not
  11687. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11688. */
  11689. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11690. /**
  11691. * The effect that is created when initializing the post process.
  11692. * @returns The created effect corresponding the the postprocess.
  11693. */
  11694. getEffect(): Effect;
  11695. /**
  11696. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11697. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11698. */
  11699. getContent(): Nullable<ArrayBufferView>;
  11700. private _createIndexBuffer;
  11701. /** @hidden */
  11702. _rebuild(): void;
  11703. /**
  11704. * Resets the texture in order to recreate its associated resources.
  11705. * This can be called in case of context loss
  11706. */
  11707. reset(): void;
  11708. protected _getDefines(): string;
  11709. /**
  11710. * Is the texture ready to be used ? (rendered at least once)
  11711. * @returns true if ready, otherwise, false.
  11712. */
  11713. isReady(): boolean;
  11714. /**
  11715. * Resets the refresh counter of the texture and start bak from scratch.
  11716. * Could be useful to regenerate the texture if it is setup to render only once.
  11717. */
  11718. resetRefreshCounter(): void;
  11719. /**
  11720. * Set the fragment shader to use in order to render the texture.
  11721. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11722. */
  11723. setFragment(fragment: any): void;
  11724. /**
  11725. * Define the refresh rate of the texture or the rendering frequency.
  11726. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11727. */
  11728. get refreshRate(): number;
  11729. set refreshRate(value: number);
  11730. /** @hidden */
  11731. _shouldRender(): boolean;
  11732. /**
  11733. * Get the size the texture is rendering at.
  11734. * @returns the size (texture is always squared)
  11735. */
  11736. getRenderSize(): number;
  11737. /**
  11738. * Resize the texture to new value.
  11739. * @param size Define the new size the texture should have
  11740. * @param generateMipMaps Define whether the new texture should create mip maps
  11741. */
  11742. resize(size: number, generateMipMaps: boolean): void;
  11743. private _checkUniform;
  11744. /**
  11745. * Set a texture in the shader program used to render.
  11746. * @param name Define the name of the uniform samplers as defined in the shader
  11747. * @param texture Define the texture to bind to this sampler
  11748. * @return the texture itself allowing "fluent" like uniform updates
  11749. */
  11750. setTexture(name: string, texture: Texture): ProceduralTexture;
  11751. /**
  11752. * Set a float in the shader.
  11753. * @param name Define the name of the uniform as defined in the shader
  11754. * @param value Define the value to give to the uniform
  11755. * @return the texture itself allowing "fluent" like uniform updates
  11756. */
  11757. setFloat(name: string, value: number): ProceduralTexture;
  11758. /**
  11759. * Set a int in the shader.
  11760. * @param name Define the name of the uniform as defined in the shader
  11761. * @param value Define the value to give to the uniform
  11762. * @return the texture itself allowing "fluent" like uniform updates
  11763. */
  11764. setInt(name: string, value: number): ProceduralTexture;
  11765. /**
  11766. * Set an array of floats in the shader.
  11767. * @param name Define the name of the uniform as defined in the shader
  11768. * @param value Define the value to give to the uniform
  11769. * @return the texture itself allowing "fluent" like uniform updates
  11770. */
  11771. setFloats(name: string, value: number[]): ProceduralTexture;
  11772. /**
  11773. * Set a vec3 in the shader from a Color3.
  11774. * @param name Define the name of the uniform as defined in the shader
  11775. * @param value Define the value to give to the uniform
  11776. * @return the texture itself allowing "fluent" like uniform updates
  11777. */
  11778. setColor3(name: string, value: Color3): ProceduralTexture;
  11779. /**
  11780. * Set a vec4 in the shader from a Color4.
  11781. * @param name Define the name of the uniform as defined in the shader
  11782. * @param value Define the value to give to the uniform
  11783. * @return the texture itself allowing "fluent" like uniform updates
  11784. */
  11785. setColor4(name: string, value: Color4): ProceduralTexture;
  11786. /**
  11787. * Set a vec2 in the shader from a Vector2.
  11788. * @param name Define the name of the uniform as defined in the shader
  11789. * @param value Define the value to give to the uniform
  11790. * @return the texture itself allowing "fluent" like uniform updates
  11791. */
  11792. setVector2(name: string, value: Vector2): ProceduralTexture;
  11793. /**
  11794. * Set a vec3 in the shader from a Vector3.
  11795. * @param name Define the name of the uniform as defined in the shader
  11796. * @param value Define the value to give to the uniform
  11797. * @return the texture itself allowing "fluent" like uniform updates
  11798. */
  11799. setVector3(name: string, value: Vector3): ProceduralTexture;
  11800. /**
  11801. * Set a mat4 in the shader from a MAtrix.
  11802. * @param name Define the name of the uniform as defined in the shader
  11803. * @param value Define the value to give to the uniform
  11804. * @return the texture itself allowing "fluent" like uniform updates
  11805. */
  11806. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11807. /**
  11808. * Render the texture to its associated render target.
  11809. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11810. */
  11811. render(useCameraPostProcess?: boolean): void;
  11812. /**
  11813. * Clone the texture.
  11814. * @returns the cloned texture
  11815. */
  11816. clone(): ProceduralTexture;
  11817. /**
  11818. * Dispose the texture and release its asoociated resources.
  11819. */
  11820. dispose(): void;
  11821. }
  11822. }
  11823. declare module BABYLON {
  11824. /**
  11825. * This represents the base class for particle system in Babylon.
  11826. * 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.
  11827. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11828. * @example https://doc.babylonjs.com/babylon101/particles
  11829. */
  11830. export class BaseParticleSystem {
  11831. /**
  11832. * Source color is added to the destination color without alpha affecting the result
  11833. */
  11834. static BLENDMODE_ONEONE: number;
  11835. /**
  11836. * Blend current color and particle color using particle’s alpha
  11837. */
  11838. static BLENDMODE_STANDARD: number;
  11839. /**
  11840. * Add current color and particle color multiplied by particle’s alpha
  11841. */
  11842. static BLENDMODE_ADD: number;
  11843. /**
  11844. * Multiply current color with particle color
  11845. */
  11846. static BLENDMODE_MULTIPLY: number;
  11847. /**
  11848. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11849. */
  11850. static BLENDMODE_MULTIPLYADD: number;
  11851. /**
  11852. * List of animations used by the particle system.
  11853. */
  11854. animations: Animation[];
  11855. /**
  11856. * Gets or sets the unique id of the particle system
  11857. */
  11858. uniqueId: number;
  11859. /**
  11860. * The id of the Particle system.
  11861. */
  11862. id: string;
  11863. /**
  11864. * The friendly name of the Particle system.
  11865. */
  11866. name: string;
  11867. /**
  11868. * Snippet ID if the particle system was created from the snippet server
  11869. */
  11870. snippetId: string;
  11871. /**
  11872. * The rendering group used by the Particle system to chose when to render.
  11873. */
  11874. renderingGroupId: number;
  11875. /**
  11876. * The emitter represents the Mesh or position we are attaching the particle system to.
  11877. */
  11878. emitter: Nullable<AbstractMesh | Vector3>;
  11879. /**
  11880. * The maximum number of particles to emit per frame
  11881. */
  11882. emitRate: number;
  11883. /**
  11884. * If you want to launch only a few particles at once, that can be done, as well.
  11885. */
  11886. manualEmitCount: number;
  11887. /**
  11888. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11889. */
  11890. updateSpeed: number;
  11891. /**
  11892. * The amount of time the particle system is running (depends of the overall update speed).
  11893. */
  11894. targetStopDuration: number;
  11895. /**
  11896. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11897. */
  11898. disposeOnStop: boolean;
  11899. /**
  11900. * Minimum power of emitting particles.
  11901. */
  11902. minEmitPower: number;
  11903. /**
  11904. * Maximum power of emitting particles.
  11905. */
  11906. maxEmitPower: number;
  11907. /**
  11908. * Minimum life time of emitting particles.
  11909. */
  11910. minLifeTime: number;
  11911. /**
  11912. * Maximum life time of emitting particles.
  11913. */
  11914. maxLifeTime: number;
  11915. /**
  11916. * Minimum Size of emitting particles.
  11917. */
  11918. minSize: number;
  11919. /**
  11920. * Maximum Size of emitting particles.
  11921. */
  11922. maxSize: number;
  11923. /**
  11924. * Minimum scale of emitting particles on X axis.
  11925. */
  11926. minScaleX: number;
  11927. /**
  11928. * Maximum scale of emitting particles on X axis.
  11929. */
  11930. maxScaleX: number;
  11931. /**
  11932. * Minimum scale of emitting particles on Y axis.
  11933. */
  11934. minScaleY: number;
  11935. /**
  11936. * Maximum scale of emitting particles on Y axis.
  11937. */
  11938. maxScaleY: number;
  11939. /**
  11940. * Gets or sets the minimal initial rotation in radians.
  11941. */
  11942. minInitialRotation: number;
  11943. /**
  11944. * Gets or sets the maximal initial rotation in radians.
  11945. */
  11946. maxInitialRotation: number;
  11947. /**
  11948. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11949. */
  11950. minAngularSpeed: number;
  11951. /**
  11952. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11953. */
  11954. maxAngularSpeed: number;
  11955. /**
  11956. * The texture used to render each particle. (this can be a spritesheet)
  11957. */
  11958. particleTexture: Nullable<Texture>;
  11959. /**
  11960. * The layer mask we are rendering the particles through.
  11961. */
  11962. layerMask: number;
  11963. /**
  11964. * This can help using your own shader to render the particle system.
  11965. * The according effect will be created
  11966. */
  11967. customShader: any;
  11968. /**
  11969. * By default particle system starts as soon as they are created. This prevents the
  11970. * automatic start to happen and let you decide when to start emitting particles.
  11971. */
  11972. preventAutoStart: boolean;
  11973. private _noiseTexture;
  11974. /**
  11975. * Gets or sets a texture used to add random noise to particle positions
  11976. */
  11977. get noiseTexture(): Nullable<ProceduralTexture>;
  11978. set noiseTexture(value: Nullable<ProceduralTexture>);
  11979. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11980. noiseStrength: Vector3;
  11981. /**
  11982. * Callback triggered when the particle animation is ending.
  11983. */
  11984. onAnimationEnd: Nullable<() => void>;
  11985. /**
  11986. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11987. */
  11988. blendMode: number;
  11989. /**
  11990. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11991. * to override the particles.
  11992. */
  11993. forceDepthWrite: boolean;
  11994. /** 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 */
  11995. preWarmCycles: number;
  11996. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11997. preWarmStepOffset: number;
  11998. /**
  11999. * 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)
  12000. */
  12001. spriteCellChangeSpeed: number;
  12002. /**
  12003. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12004. */
  12005. startSpriteCellID: number;
  12006. /**
  12007. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12008. */
  12009. endSpriteCellID: number;
  12010. /**
  12011. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12012. */
  12013. spriteCellWidth: number;
  12014. /**
  12015. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12016. */
  12017. spriteCellHeight: number;
  12018. /**
  12019. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12020. */
  12021. spriteRandomStartCell: boolean;
  12022. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12023. translationPivot: Vector2;
  12024. /** @hidden */
  12025. protected _isAnimationSheetEnabled: boolean;
  12026. /**
  12027. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12028. */
  12029. beginAnimationOnStart: boolean;
  12030. /**
  12031. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12032. */
  12033. beginAnimationFrom: number;
  12034. /**
  12035. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12036. */
  12037. beginAnimationTo: number;
  12038. /**
  12039. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12040. */
  12041. beginAnimationLoop: boolean;
  12042. /**
  12043. * Gets or sets a world offset applied to all particles
  12044. */
  12045. worldOffset: Vector3;
  12046. /**
  12047. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12048. */
  12049. get isAnimationSheetEnabled(): boolean;
  12050. set isAnimationSheetEnabled(value: boolean);
  12051. /**
  12052. * Get hosting scene
  12053. * @returns the scene
  12054. */
  12055. getScene(): Scene;
  12056. /**
  12057. * You can use gravity if you want to give an orientation to your particles.
  12058. */
  12059. gravity: Vector3;
  12060. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12061. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12062. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12063. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12064. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12065. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12066. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12067. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12068. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12069. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12070. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12071. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12072. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12073. /**
  12074. * Defines the delay in milliseconds before starting the system (0 by default)
  12075. */
  12076. startDelay: number;
  12077. /**
  12078. * Gets the current list of drag gradients.
  12079. * You must use addDragGradient and removeDragGradient to udpate this list
  12080. * @returns the list of drag gradients
  12081. */
  12082. getDragGradients(): Nullable<Array<FactorGradient>>;
  12083. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12084. limitVelocityDamping: number;
  12085. /**
  12086. * Gets the current list of limit velocity gradients.
  12087. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12088. * @returns the list of limit velocity gradients
  12089. */
  12090. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12091. /**
  12092. * Gets the current list of color gradients.
  12093. * You must use addColorGradient and removeColorGradient to udpate this list
  12094. * @returns the list of color gradients
  12095. */
  12096. getColorGradients(): Nullable<Array<ColorGradient>>;
  12097. /**
  12098. * Gets the current list of size gradients.
  12099. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12100. * @returns the list of size gradients
  12101. */
  12102. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12103. /**
  12104. * Gets the current list of color remap gradients.
  12105. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12106. * @returns the list of color remap gradients
  12107. */
  12108. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12109. /**
  12110. * Gets the current list of alpha remap gradients.
  12111. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12112. * @returns the list of alpha remap gradients
  12113. */
  12114. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12115. /**
  12116. * Gets the current list of life time gradients.
  12117. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12118. * @returns the list of life time gradients
  12119. */
  12120. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12121. /**
  12122. * Gets the current list of angular speed gradients.
  12123. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12124. * @returns the list of angular speed gradients
  12125. */
  12126. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12127. /**
  12128. * Gets the current list of velocity gradients.
  12129. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12130. * @returns the list of velocity gradients
  12131. */
  12132. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12133. /**
  12134. * Gets the current list of start size gradients.
  12135. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12136. * @returns the list of start size gradients
  12137. */
  12138. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12139. /**
  12140. * Gets the current list of emit rate gradients.
  12141. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12142. * @returns the list of emit rate gradients
  12143. */
  12144. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12145. /**
  12146. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12147. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12148. */
  12149. get direction1(): Vector3;
  12150. set direction1(value: Vector3);
  12151. /**
  12152. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12153. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12154. */
  12155. get direction2(): Vector3;
  12156. set direction2(value: Vector3);
  12157. /**
  12158. * 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.
  12159. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12160. */
  12161. get minEmitBox(): Vector3;
  12162. set minEmitBox(value: Vector3);
  12163. /**
  12164. * 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.
  12165. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12166. */
  12167. get maxEmitBox(): Vector3;
  12168. set maxEmitBox(value: Vector3);
  12169. /**
  12170. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12171. */
  12172. color1: Color4;
  12173. /**
  12174. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12175. */
  12176. color2: Color4;
  12177. /**
  12178. * Color the particle will have at the end of its lifetime
  12179. */
  12180. colorDead: Color4;
  12181. /**
  12182. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12183. */
  12184. textureMask: Color4;
  12185. /**
  12186. * The particle emitter type defines the emitter used by the particle system.
  12187. * It can be for example box, sphere, or cone...
  12188. */
  12189. particleEmitterType: IParticleEmitterType;
  12190. /** @hidden */
  12191. _isSubEmitter: boolean;
  12192. /**
  12193. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12194. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12195. */
  12196. billboardMode: number;
  12197. protected _isBillboardBased: boolean;
  12198. /**
  12199. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12200. */
  12201. get isBillboardBased(): boolean;
  12202. set isBillboardBased(value: boolean);
  12203. /**
  12204. * The scene the particle system belongs to.
  12205. */
  12206. protected _scene: Scene;
  12207. /**
  12208. * Local cache of defines for image processing.
  12209. */
  12210. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12211. /**
  12212. * Default configuration related to image processing available in the standard Material.
  12213. */
  12214. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  12215. /**
  12216. * Gets the image processing configuration used either in this material.
  12217. */
  12218. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  12219. /**
  12220. * Sets the Default image processing configuration used either in the this material.
  12221. *
  12222. * If sets to null, the scene one is in use.
  12223. */
  12224. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  12225. /**
  12226. * Attaches a new image processing configuration to the Standard Material.
  12227. * @param configuration
  12228. */
  12229. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12230. /** @hidden */
  12231. protected _reset(): void;
  12232. /** @hidden */
  12233. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12234. /**
  12235. * Instantiates a particle system.
  12236. * 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.
  12237. * @param name The name of the particle system
  12238. */
  12239. constructor(name: string);
  12240. /**
  12241. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12242. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12243. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12244. * @returns the emitter
  12245. */
  12246. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12247. /**
  12248. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12249. * @param radius The radius of the hemisphere to emit from
  12250. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12251. * @returns the emitter
  12252. */
  12253. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12254. /**
  12255. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12256. * @param radius The radius of the sphere to emit from
  12257. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12258. * @returns the emitter
  12259. */
  12260. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12261. /**
  12262. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12263. * @param radius The radius of the sphere to emit from
  12264. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12265. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12266. * @returns the emitter
  12267. */
  12268. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12269. /**
  12270. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12271. * @param radius The radius of the emission cylinder
  12272. * @param height The height of the emission cylinder
  12273. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12274. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12275. * @returns the emitter
  12276. */
  12277. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12278. /**
  12279. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12280. * @param radius The radius of the cylinder to emit from
  12281. * @param height The height of the emission cylinder
  12282. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12283. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12284. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12285. * @returns the emitter
  12286. */
  12287. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12288. /**
  12289. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12290. * @param radius The radius of the cone to emit from
  12291. * @param angle The base angle of the cone
  12292. * @returns the emitter
  12293. */
  12294. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12295. /**
  12296. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12297. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12298. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12299. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12300. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12301. * @returns the emitter
  12302. */
  12303. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12304. }
  12305. }
  12306. declare module BABYLON {
  12307. /**
  12308. * Type of sub emitter
  12309. */
  12310. export enum SubEmitterType {
  12311. /**
  12312. * Attached to the particle over it's lifetime
  12313. */
  12314. ATTACHED = 0,
  12315. /**
  12316. * Created when the particle dies
  12317. */
  12318. END = 1
  12319. }
  12320. /**
  12321. * Sub emitter class used to emit particles from an existing particle
  12322. */
  12323. export class SubEmitter {
  12324. /**
  12325. * the particle system to be used by the sub emitter
  12326. */
  12327. particleSystem: ParticleSystem;
  12328. /**
  12329. * Type of the submitter (Default: END)
  12330. */
  12331. type: SubEmitterType;
  12332. /**
  12333. * 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)
  12334. * Note: This only is supported when using an emitter of type Mesh
  12335. */
  12336. inheritDirection: boolean;
  12337. /**
  12338. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12339. */
  12340. inheritedVelocityAmount: number;
  12341. /**
  12342. * Creates a sub emitter
  12343. * @param particleSystem the particle system to be used by the sub emitter
  12344. */
  12345. constructor(
  12346. /**
  12347. * the particle system to be used by the sub emitter
  12348. */
  12349. particleSystem: ParticleSystem);
  12350. /**
  12351. * Clones the sub emitter
  12352. * @returns the cloned sub emitter
  12353. */
  12354. clone(): SubEmitter;
  12355. /**
  12356. * Serialize current object to a JSON object
  12357. * @returns the serialized object
  12358. */
  12359. serialize(): any;
  12360. /** @hidden */
  12361. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  12362. /**
  12363. * Creates a new SubEmitter from a serialized JSON version
  12364. * @param serializationObject defines the JSON object to read from
  12365. * @param scene defines the hosting scene
  12366. * @param rootUrl defines the rootUrl for data loading
  12367. * @returns a new SubEmitter
  12368. */
  12369. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  12370. /** Release associated resources */
  12371. dispose(): void;
  12372. }
  12373. }
  12374. declare module BABYLON {
  12375. /** @hidden */
  12376. export var imageProcessingDeclaration: {
  12377. name: string;
  12378. shader: string;
  12379. };
  12380. }
  12381. declare module BABYLON {
  12382. /** @hidden */
  12383. export var imageProcessingFunctions: {
  12384. name: string;
  12385. shader: string;
  12386. };
  12387. }
  12388. declare module BABYLON {
  12389. /** @hidden */
  12390. export var particlesPixelShader: {
  12391. name: string;
  12392. shader: string;
  12393. };
  12394. }
  12395. declare module BABYLON {
  12396. /** @hidden */
  12397. export var particlesVertexShader: {
  12398. name: string;
  12399. shader: string;
  12400. };
  12401. }
  12402. declare module BABYLON {
  12403. /**
  12404. * This represents a particle system in Babylon.
  12405. * 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.
  12406. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12407. * @example https://doc.babylonjs.com/babylon101/particles
  12408. */
  12409. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12410. /**
  12411. * Billboard mode will only apply to Y axis
  12412. */
  12413. static readonly BILLBOARDMODE_Y: number;
  12414. /**
  12415. * Billboard mode will apply to all axes
  12416. */
  12417. static readonly BILLBOARDMODE_ALL: number;
  12418. /**
  12419. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12420. */
  12421. static readonly BILLBOARDMODE_STRETCHED: number;
  12422. /**
  12423. * This function can be defined to provide custom update for active particles.
  12424. * This function will be called instead of regular update (age, position, color, etc.).
  12425. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12426. */
  12427. updateFunction: (particles: Particle[]) => void;
  12428. private _emitterWorldMatrix;
  12429. /**
  12430. * This function can be defined to specify initial direction for every new particle.
  12431. * It by default use the emitterType defined function
  12432. */
  12433. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12434. /**
  12435. * This function can be defined to specify initial position for every new particle.
  12436. * It by default use the emitterType defined function
  12437. */
  12438. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12439. /**
  12440. * @hidden
  12441. */
  12442. _inheritedVelocityOffset: Vector3;
  12443. /**
  12444. * An event triggered when the system is disposed
  12445. */
  12446. onDisposeObservable: Observable<IParticleSystem>;
  12447. private _onDisposeObserver;
  12448. /**
  12449. * Sets a callback that will be triggered when the system is disposed
  12450. */
  12451. set onDispose(callback: () => void);
  12452. private _particles;
  12453. private _epsilon;
  12454. private _capacity;
  12455. private _stockParticles;
  12456. private _newPartsExcess;
  12457. private _vertexData;
  12458. private _vertexBuffer;
  12459. private _vertexBuffers;
  12460. private _spriteBuffer;
  12461. private _indexBuffer;
  12462. private _effect;
  12463. private _customEffect;
  12464. private _cachedDefines;
  12465. private _scaledColorStep;
  12466. private _colorDiff;
  12467. private _scaledDirection;
  12468. private _scaledGravity;
  12469. private _currentRenderId;
  12470. private _alive;
  12471. private _useInstancing;
  12472. private _started;
  12473. private _stopped;
  12474. private _actualFrame;
  12475. private _scaledUpdateSpeed;
  12476. private _vertexBufferSize;
  12477. /** @hidden */
  12478. _currentEmitRateGradient: Nullable<FactorGradient>;
  12479. /** @hidden */
  12480. _currentEmitRate1: number;
  12481. /** @hidden */
  12482. _currentEmitRate2: number;
  12483. /** @hidden */
  12484. _currentStartSizeGradient: Nullable<FactorGradient>;
  12485. /** @hidden */
  12486. _currentStartSize1: number;
  12487. /** @hidden */
  12488. _currentStartSize2: number;
  12489. private readonly _rawTextureWidth;
  12490. private _rampGradientsTexture;
  12491. private _useRampGradients;
  12492. /** Gets or sets a boolean indicating that ramp gradients must be used
  12493. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12494. */
  12495. get useRampGradients(): boolean;
  12496. set useRampGradients(value: boolean);
  12497. /**
  12498. * 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.
  12499. * 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: [])
  12500. */
  12501. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12502. private _subEmitters;
  12503. /**
  12504. * @hidden
  12505. * If the particle systems emitter should be disposed when the particle system is disposed
  12506. */
  12507. _disposeEmitterOnDispose: boolean;
  12508. /**
  12509. * The current active Sub-systems, this property is used by the root particle system only.
  12510. */
  12511. activeSubSystems: Array<ParticleSystem>;
  12512. /**
  12513. * Specifies if the particles are updated in emitter local space or world space
  12514. */
  12515. isLocal: boolean;
  12516. private _rootParticleSystem;
  12517. /**
  12518. * Gets the current list of active particles
  12519. */
  12520. get particles(): Particle[];
  12521. /**
  12522. * Gets the number of particles active at the same time.
  12523. * @returns The number of active particles.
  12524. */
  12525. getActiveCount(): number;
  12526. /**
  12527. * Returns the string "ParticleSystem"
  12528. * @returns a string containing the class name
  12529. */
  12530. getClassName(): string;
  12531. /**
  12532. * Gets a boolean indicating that the system is stopping
  12533. * @returns true if the system is currently stopping
  12534. */
  12535. isStopping(): boolean;
  12536. /**
  12537. * Gets the custom effect used to render the particles
  12538. * @param blendMode Blend mode for which the effect should be retrieved
  12539. * @returns The effect
  12540. */
  12541. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12542. /**
  12543. * Sets the custom effect used to render the particles
  12544. * @param effect The effect to set
  12545. * @param blendMode Blend mode for which the effect should be set
  12546. */
  12547. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12548. /** @hidden */
  12549. private _onBeforeDrawParticlesObservable;
  12550. /**
  12551. * Observable that will be called just before the particles are drawn
  12552. */
  12553. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12554. /**
  12555. * Gets the name of the particle vertex shader
  12556. */
  12557. get vertexShaderName(): string;
  12558. /**
  12559. * Instantiates a particle system.
  12560. * 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.
  12561. * @param name The name of the particle system
  12562. * @param capacity The max number of particles alive at the same time
  12563. * @param scene The scene the particle system belongs to
  12564. * @param customEffect a custom effect used to change the way particles are rendered by default
  12565. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12566. * @param epsilon Offset used to render the particles
  12567. */
  12568. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12569. private _addFactorGradient;
  12570. private _removeFactorGradient;
  12571. /**
  12572. * Adds a new life time gradient
  12573. * @param gradient defines the gradient to use (between 0 and 1)
  12574. * @param factor defines the life time factor to affect to the specified gradient
  12575. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12576. * @returns the current particle system
  12577. */
  12578. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12579. /**
  12580. * Remove a specific life time gradient
  12581. * @param gradient defines the gradient to remove
  12582. * @returns the current particle system
  12583. */
  12584. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12585. /**
  12586. * Adds a new size gradient
  12587. * @param gradient defines the gradient to use (between 0 and 1)
  12588. * @param factor defines the size factor to affect to the specified gradient
  12589. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12590. * @returns the current particle system
  12591. */
  12592. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12593. /**
  12594. * Remove a specific size gradient
  12595. * @param gradient defines the gradient to remove
  12596. * @returns the current particle system
  12597. */
  12598. removeSizeGradient(gradient: number): IParticleSystem;
  12599. /**
  12600. * Adds a new color remap gradient
  12601. * @param gradient defines the gradient to use (between 0 and 1)
  12602. * @param min defines the color remap minimal range
  12603. * @param max defines the color remap maximal range
  12604. * @returns the current particle system
  12605. */
  12606. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12607. /**
  12608. * Remove a specific color remap gradient
  12609. * @param gradient defines the gradient to remove
  12610. * @returns the current particle system
  12611. */
  12612. removeColorRemapGradient(gradient: number): IParticleSystem;
  12613. /**
  12614. * Adds a new alpha remap gradient
  12615. * @param gradient defines the gradient to use (between 0 and 1)
  12616. * @param min defines the alpha remap minimal range
  12617. * @param max defines the alpha remap maximal range
  12618. * @returns the current particle system
  12619. */
  12620. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12621. /**
  12622. * Remove a specific alpha remap gradient
  12623. * @param gradient defines the gradient to remove
  12624. * @returns the current particle system
  12625. */
  12626. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12627. /**
  12628. * Adds a new angular speed gradient
  12629. * @param gradient defines the gradient to use (between 0 and 1)
  12630. * @param factor defines the angular speed to affect to the specified gradient
  12631. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12632. * @returns the current particle system
  12633. */
  12634. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12635. /**
  12636. * Remove a specific angular speed gradient
  12637. * @param gradient defines the gradient to remove
  12638. * @returns the current particle system
  12639. */
  12640. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12641. /**
  12642. * Adds a new velocity gradient
  12643. * @param gradient defines the gradient to use (between 0 and 1)
  12644. * @param factor defines the velocity to affect to the specified gradient
  12645. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12646. * @returns the current particle system
  12647. */
  12648. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12649. /**
  12650. * Remove a specific velocity gradient
  12651. * @param gradient defines the gradient to remove
  12652. * @returns the current particle system
  12653. */
  12654. removeVelocityGradient(gradient: number): IParticleSystem;
  12655. /**
  12656. * Adds a new limit velocity gradient
  12657. * @param gradient defines the gradient to use (between 0 and 1)
  12658. * @param factor defines the limit velocity value to affect to the specified gradient
  12659. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12660. * @returns the current particle system
  12661. */
  12662. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12663. /**
  12664. * Remove a specific limit velocity gradient
  12665. * @param gradient defines the gradient to remove
  12666. * @returns the current particle system
  12667. */
  12668. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12669. /**
  12670. * Adds a new drag gradient
  12671. * @param gradient defines the gradient to use (between 0 and 1)
  12672. * @param factor defines the drag value to affect to the specified gradient
  12673. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12674. * @returns the current particle system
  12675. */
  12676. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12677. /**
  12678. * Remove a specific drag gradient
  12679. * @param gradient defines the gradient to remove
  12680. * @returns the current particle system
  12681. */
  12682. removeDragGradient(gradient: number): IParticleSystem;
  12683. /**
  12684. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12685. * @param gradient defines the gradient to use (between 0 and 1)
  12686. * @param factor defines the emit rate value to affect to the specified gradient
  12687. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12688. * @returns the current particle system
  12689. */
  12690. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12691. /**
  12692. * Remove a specific emit rate gradient
  12693. * @param gradient defines the gradient to remove
  12694. * @returns the current particle system
  12695. */
  12696. removeEmitRateGradient(gradient: number): IParticleSystem;
  12697. /**
  12698. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12699. * @param gradient defines the gradient to use (between 0 and 1)
  12700. * @param factor defines the start size value to affect to the specified gradient
  12701. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12702. * @returns the current particle system
  12703. */
  12704. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12705. /**
  12706. * Remove a specific start size gradient
  12707. * @param gradient defines the gradient to remove
  12708. * @returns the current particle system
  12709. */
  12710. removeStartSizeGradient(gradient: number): IParticleSystem;
  12711. private _createRampGradientTexture;
  12712. /**
  12713. * Gets the current list of ramp gradients.
  12714. * You must use addRampGradient and removeRampGradient to udpate this list
  12715. * @returns the list of ramp gradients
  12716. */
  12717. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12718. /** Force the system to rebuild all gradients that need to be resync */
  12719. forceRefreshGradients(): void;
  12720. private _syncRampGradientTexture;
  12721. /**
  12722. * Adds a new ramp gradient used to remap particle colors
  12723. * @param gradient defines the gradient to use (between 0 and 1)
  12724. * @param color defines the color to affect to the specified gradient
  12725. * @returns the current particle system
  12726. */
  12727. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12728. /**
  12729. * Remove a specific ramp gradient
  12730. * @param gradient defines the gradient to remove
  12731. * @returns the current particle system
  12732. */
  12733. removeRampGradient(gradient: number): ParticleSystem;
  12734. /**
  12735. * Adds a new color gradient
  12736. * @param gradient defines the gradient to use (between 0 and 1)
  12737. * @param color1 defines the color to affect to the specified gradient
  12738. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12739. * @returns this particle system
  12740. */
  12741. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12742. /**
  12743. * Remove a specific color gradient
  12744. * @param gradient defines the gradient to remove
  12745. * @returns this particle system
  12746. */
  12747. removeColorGradient(gradient: number): IParticleSystem;
  12748. private _fetchR;
  12749. protected _reset(): void;
  12750. private _resetEffect;
  12751. private _createVertexBuffers;
  12752. private _createIndexBuffer;
  12753. /**
  12754. * Gets the maximum number of particles active at the same time.
  12755. * @returns The max number of active particles.
  12756. */
  12757. getCapacity(): number;
  12758. /**
  12759. * Gets whether there are still active particles in the system.
  12760. * @returns True if it is alive, otherwise false.
  12761. */
  12762. isAlive(): boolean;
  12763. /**
  12764. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12765. * @returns True if it has been started, otherwise false.
  12766. */
  12767. isStarted(): boolean;
  12768. private _prepareSubEmitterInternalArray;
  12769. /**
  12770. * Starts the particle system and begins to emit
  12771. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12772. */
  12773. start(delay?: number): void;
  12774. /**
  12775. * Stops the particle system.
  12776. * @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.
  12777. */
  12778. stop(stopSubEmitters?: boolean): void;
  12779. /**
  12780. * Remove all active particles
  12781. */
  12782. reset(): void;
  12783. /**
  12784. * @hidden (for internal use only)
  12785. */
  12786. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12787. /**
  12788. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12789. * Its lifetime will start back at 0.
  12790. */
  12791. recycleParticle: (particle: Particle) => void;
  12792. private _stopSubEmitters;
  12793. private _createParticle;
  12794. private _removeFromRoot;
  12795. private _emitFromParticle;
  12796. private _update;
  12797. /** @hidden */
  12798. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12799. /** @hidden */
  12800. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12801. /**
  12802. * Fill the defines array according to the current settings of the particle system
  12803. * @param defines Array to be updated
  12804. * @param blendMode blend mode to take into account when updating the array
  12805. */
  12806. fillDefines(defines: Array<string>, blendMode: number): void;
  12807. /**
  12808. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  12809. * @param uniforms Uniforms array to fill
  12810. * @param attributes Attributes array to fill
  12811. * @param samplers Samplers array to fill
  12812. */
  12813. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  12814. /** @hidden */
  12815. private _getEffect;
  12816. /**
  12817. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12818. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12819. */
  12820. animate(preWarmOnly?: boolean): void;
  12821. private _appendParticleVertices;
  12822. /**
  12823. * Rebuilds the particle system.
  12824. */
  12825. rebuild(): void;
  12826. /**
  12827. * Is this system ready to be used/rendered
  12828. * @return true if the system is ready
  12829. */
  12830. isReady(): boolean;
  12831. private _render;
  12832. /**
  12833. * Renders the particle system in its current state.
  12834. * @returns the current number of particles
  12835. */
  12836. render(): number;
  12837. /**
  12838. * Disposes the particle system and free the associated resources
  12839. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12840. */
  12841. dispose(disposeTexture?: boolean): void;
  12842. /**
  12843. * Clones the particle system.
  12844. * @param name The name of the cloned object
  12845. * @param newEmitter The new emitter to use
  12846. * @returns the cloned particle system
  12847. */
  12848. clone(name: string, newEmitter: any): ParticleSystem;
  12849. /**
  12850. * Serializes the particle system to a JSON object
  12851. * @param serializeTexture defines if the texture must be serialized as well
  12852. * @returns the JSON object
  12853. */
  12854. serialize(serializeTexture?: boolean): any;
  12855. /** @hidden */
  12856. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12857. /** @hidden */
  12858. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12859. /**
  12860. * Parses a JSON object to create a particle system.
  12861. * @param parsedParticleSystem The JSON object to parse
  12862. * @param scene The scene to create the particle system in
  12863. * @param rootUrl The root url to use to load external dependencies like texture
  12864. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12865. * @returns the Parsed particle system
  12866. */
  12867. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12868. }
  12869. }
  12870. declare module BABYLON {
  12871. /**
  12872. * A particle represents one of the element emitted by a particle system.
  12873. * This is mainly define by its coordinates, direction, velocity and age.
  12874. */
  12875. export class Particle {
  12876. /**
  12877. * The particle system the particle belongs to.
  12878. */
  12879. particleSystem: ParticleSystem;
  12880. private static _Count;
  12881. /**
  12882. * Unique ID of the particle
  12883. */
  12884. id: number;
  12885. /**
  12886. * The world position of the particle in the scene.
  12887. */
  12888. position: Vector3;
  12889. /**
  12890. * The world direction of the particle in the scene.
  12891. */
  12892. direction: Vector3;
  12893. /**
  12894. * The color of the particle.
  12895. */
  12896. color: Color4;
  12897. /**
  12898. * The color change of the particle per step.
  12899. */
  12900. colorStep: Color4;
  12901. /**
  12902. * Defines how long will the life of the particle be.
  12903. */
  12904. lifeTime: number;
  12905. /**
  12906. * The current age of the particle.
  12907. */
  12908. age: number;
  12909. /**
  12910. * The current size of the particle.
  12911. */
  12912. size: number;
  12913. /**
  12914. * The current scale of the particle.
  12915. */
  12916. scale: Vector2;
  12917. /**
  12918. * The current angle of the particle.
  12919. */
  12920. angle: number;
  12921. /**
  12922. * Defines how fast is the angle changing.
  12923. */
  12924. angularSpeed: number;
  12925. /**
  12926. * Defines the cell index used by the particle to be rendered from a sprite.
  12927. */
  12928. cellIndex: number;
  12929. /**
  12930. * The information required to support color remapping
  12931. */
  12932. remapData: Vector4;
  12933. /** @hidden */
  12934. _randomCellOffset?: number;
  12935. /** @hidden */
  12936. _initialDirection: Nullable<Vector3>;
  12937. /** @hidden */
  12938. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12939. /** @hidden */
  12940. _initialStartSpriteCellID: number;
  12941. /** @hidden */
  12942. _initialEndSpriteCellID: number;
  12943. /** @hidden */
  12944. _currentColorGradient: Nullable<ColorGradient>;
  12945. /** @hidden */
  12946. _currentColor1: Color4;
  12947. /** @hidden */
  12948. _currentColor2: Color4;
  12949. /** @hidden */
  12950. _currentSizeGradient: Nullable<FactorGradient>;
  12951. /** @hidden */
  12952. _currentSize1: number;
  12953. /** @hidden */
  12954. _currentSize2: number;
  12955. /** @hidden */
  12956. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12957. /** @hidden */
  12958. _currentAngularSpeed1: number;
  12959. /** @hidden */
  12960. _currentAngularSpeed2: number;
  12961. /** @hidden */
  12962. _currentVelocityGradient: Nullable<FactorGradient>;
  12963. /** @hidden */
  12964. _currentVelocity1: number;
  12965. /** @hidden */
  12966. _currentVelocity2: number;
  12967. /** @hidden */
  12968. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12969. /** @hidden */
  12970. _currentLimitVelocity1: number;
  12971. /** @hidden */
  12972. _currentLimitVelocity2: number;
  12973. /** @hidden */
  12974. _currentDragGradient: Nullable<FactorGradient>;
  12975. /** @hidden */
  12976. _currentDrag1: number;
  12977. /** @hidden */
  12978. _currentDrag2: number;
  12979. /** @hidden */
  12980. _randomNoiseCoordinates1: Vector3;
  12981. /** @hidden */
  12982. _randomNoiseCoordinates2: Vector3;
  12983. /** @hidden */
  12984. _localPosition?: Vector3;
  12985. /**
  12986. * Creates a new instance Particle
  12987. * @param particleSystem the particle system the particle belongs to
  12988. */
  12989. constructor(
  12990. /**
  12991. * The particle system the particle belongs to.
  12992. */
  12993. particleSystem: ParticleSystem);
  12994. private updateCellInfoFromSystem;
  12995. /**
  12996. * Defines how the sprite cell index is updated for the particle
  12997. */
  12998. updateCellIndex(): void;
  12999. /** @hidden */
  13000. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13001. /** @hidden */
  13002. _inheritParticleInfoToSubEmitters(): void;
  13003. /** @hidden */
  13004. _reset(): void;
  13005. /**
  13006. * Copy the properties of particle to another one.
  13007. * @param other the particle to copy the information to.
  13008. */
  13009. copyTo(other: Particle): void;
  13010. }
  13011. }
  13012. declare module BABYLON {
  13013. /**
  13014. * Particle emitter represents a volume emitting particles.
  13015. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13016. */
  13017. export interface IParticleEmitterType {
  13018. /**
  13019. * Called by the particle System when the direction is computed for the created particle.
  13020. * @param worldMatrix is the world matrix of the particle system
  13021. * @param directionToUpdate is the direction vector to update with the result
  13022. * @param particle is the particle we are computed the direction for
  13023. * @param isLocal defines if the direction should be set in local space
  13024. */
  13025. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13026. /**
  13027. * Called by the particle System when the position is computed for the created particle.
  13028. * @param worldMatrix is the world matrix of the particle system
  13029. * @param positionToUpdate is the position vector to update with the result
  13030. * @param particle is the particle we are computed the position for
  13031. * @param isLocal defines if the position should be set in local space
  13032. */
  13033. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13034. /**
  13035. * Clones the current emitter and returns a copy of it
  13036. * @returns the new emitter
  13037. */
  13038. clone(): IParticleEmitterType;
  13039. /**
  13040. * Called by the GPUParticleSystem to setup the update shader
  13041. * @param effect defines the update shader
  13042. */
  13043. applyToShader(effect: Effect): void;
  13044. /**
  13045. * Returns a string to use to update the GPU particles update shader
  13046. * @returns the effect defines string
  13047. */
  13048. getEffectDefines(): string;
  13049. /**
  13050. * Returns a string representing the class name
  13051. * @returns a string containing the class name
  13052. */
  13053. getClassName(): string;
  13054. /**
  13055. * Serializes the particle system to a JSON object.
  13056. * @returns the JSON object
  13057. */
  13058. serialize(): any;
  13059. /**
  13060. * Parse properties from a JSON object
  13061. * @param serializationObject defines the JSON object
  13062. * @param scene defines the hosting scene
  13063. */
  13064. parse(serializationObject: any, scene: Scene): void;
  13065. }
  13066. }
  13067. declare module BABYLON {
  13068. /**
  13069. * Particle emitter emitting particles from the inside of a box.
  13070. * It emits the particles randomly between 2 given directions.
  13071. */
  13072. export class BoxParticleEmitter implements IParticleEmitterType {
  13073. /**
  13074. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13075. */
  13076. direction1: Vector3;
  13077. /**
  13078. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13079. */
  13080. direction2: Vector3;
  13081. /**
  13082. * 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.
  13083. */
  13084. minEmitBox: Vector3;
  13085. /**
  13086. * 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.
  13087. */
  13088. maxEmitBox: Vector3;
  13089. /**
  13090. * Creates a new instance BoxParticleEmitter
  13091. */
  13092. constructor();
  13093. /**
  13094. * Called by the particle System when the direction is computed for the created particle.
  13095. * @param worldMatrix is the world matrix of the particle system
  13096. * @param directionToUpdate is the direction vector to update with the result
  13097. * @param particle is the particle we are computed the direction for
  13098. * @param isLocal defines if the direction should be set in local space
  13099. */
  13100. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13101. /**
  13102. * Called by the particle System when the position is computed for the created particle.
  13103. * @param worldMatrix is the world matrix of the particle system
  13104. * @param positionToUpdate is the position vector to update with the result
  13105. * @param particle is the particle we are computed the position for
  13106. * @param isLocal defines if the position should be set in local space
  13107. */
  13108. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13109. /**
  13110. * Clones the current emitter and returns a copy of it
  13111. * @returns the new emitter
  13112. */
  13113. clone(): BoxParticleEmitter;
  13114. /**
  13115. * Called by the GPUParticleSystem to setup the update shader
  13116. * @param effect defines the update shader
  13117. */
  13118. applyToShader(effect: Effect): void;
  13119. /**
  13120. * Returns a string to use to update the GPU particles update shader
  13121. * @returns a string containng the defines string
  13122. */
  13123. getEffectDefines(): string;
  13124. /**
  13125. * Returns the string "BoxParticleEmitter"
  13126. * @returns a string containing the class name
  13127. */
  13128. getClassName(): string;
  13129. /**
  13130. * Serializes the particle system to a JSON object.
  13131. * @returns the JSON object
  13132. */
  13133. serialize(): any;
  13134. /**
  13135. * Parse properties from a JSON object
  13136. * @param serializationObject defines the JSON object
  13137. */
  13138. parse(serializationObject: any): void;
  13139. }
  13140. }
  13141. declare module BABYLON {
  13142. /**
  13143. * Particle emitter emitting particles from the inside of a cone.
  13144. * It emits the particles alongside the cone volume from the base to the particle.
  13145. * The emission direction might be randomized.
  13146. */
  13147. export class ConeParticleEmitter implements IParticleEmitterType {
  13148. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13149. directionRandomizer: number;
  13150. private _radius;
  13151. private _angle;
  13152. private _height;
  13153. /**
  13154. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13155. */
  13156. radiusRange: number;
  13157. /**
  13158. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13159. */
  13160. heightRange: number;
  13161. /**
  13162. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13163. */
  13164. emitFromSpawnPointOnly: boolean;
  13165. /**
  13166. * Gets or sets the radius of the emission cone
  13167. */
  13168. get radius(): number;
  13169. set radius(value: number);
  13170. /**
  13171. * Gets or sets the angle of the emission cone
  13172. */
  13173. get angle(): number;
  13174. set angle(value: number);
  13175. private _buildHeight;
  13176. /**
  13177. * Creates a new instance ConeParticleEmitter
  13178. * @param radius the radius of the emission cone (1 by default)
  13179. * @param angle the cone base angle (PI by default)
  13180. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13181. */
  13182. constructor(radius?: number, angle?: number,
  13183. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13184. directionRandomizer?: number);
  13185. /**
  13186. * Called by the particle System when the direction is computed for the created particle.
  13187. * @param worldMatrix is the world matrix of the particle system
  13188. * @param directionToUpdate is the direction vector to update with the result
  13189. * @param particle is the particle we are computed the direction for
  13190. * @param isLocal defines if the direction should be set in local space
  13191. */
  13192. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13193. /**
  13194. * Called by the particle System when the position is computed for the created particle.
  13195. * @param worldMatrix is the world matrix of the particle system
  13196. * @param positionToUpdate is the position vector to update with the result
  13197. * @param particle is the particle we are computed the position for
  13198. * @param isLocal defines if the position should be set in local space
  13199. */
  13200. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13201. /**
  13202. * Clones the current emitter and returns a copy of it
  13203. * @returns the new emitter
  13204. */
  13205. clone(): ConeParticleEmitter;
  13206. /**
  13207. * Called by the GPUParticleSystem to setup the update shader
  13208. * @param effect defines the update shader
  13209. */
  13210. applyToShader(effect: Effect): void;
  13211. /**
  13212. * Returns a string to use to update the GPU particles update shader
  13213. * @returns a string containng the defines string
  13214. */
  13215. getEffectDefines(): string;
  13216. /**
  13217. * Returns the string "ConeParticleEmitter"
  13218. * @returns a string containing the class name
  13219. */
  13220. getClassName(): string;
  13221. /**
  13222. * Serializes the particle system to a JSON object.
  13223. * @returns the JSON object
  13224. */
  13225. serialize(): any;
  13226. /**
  13227. * Parse properties from a JSON object
  13228. * @param serializationObject defines the JSON object
  13229. */
  13230. parse(serializationObject: any): void;
  13231. }
  13232. }
  13233. declare module BABYLON {
  13234. /**
  13235. * Particle emitter emitting particles from the inside of a cylinder.
  13236. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13237. */
  13238. export class CylinderParticleEmitter implements IParticleEmitterType {
  13239. /**
  13240. * The radius of the emission cylinder.
  13241. */
  13242. radius: number;
  13243. /**
  13244. * The height of the emission cylinder.
  13245. */
  13246. height: number;
  13247. /**
  13248. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13249. */
  13250. radiusRange: number;
  13251. /**
  13252. * How much to randomize the particle direction [0-1].
  13253. */
  13254. directionRandomizer: number;
  13255. /**
  13256. * Creates a new instance CylinderParticleEmitter
  13257. * @param radius the radius of the emission cylinder (1 by default)
  13258. * @param height the height of the emission cylinder (1 by default)
  13259. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13260. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13261. */
  13262. constructor(
  13263. /**
  13264. * The radius of the emission cylinder.
  13265. */
  13266. radius?: number,
  13267. /**
  13268. * The height of the emission cylinder.
  13269. */
  13270. height?: number,
  13271. /**
  13272. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13273. */
  13274. radiusRange?: number,
  13275. /**
  13276. * How much to randomize the particle direction [0-1].
  13277. */
  13278. directionRandomizer?: number);
  13279. /**
  13280. * Called by the particle System when the direction is computed for the created particle.
  13281. * @param worldMatrix is the world matrix of the particle system
  13282. * @param directionToUpdate is the direction vector to update with the result
  13283. * @param particle is the particle we are computed the direction for
  13284. * @param isLocal defines if the direction should be set in local space
  13285. */
  13286. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13287. /**
  13288. * Called by the particle System when the position is computed for the created particle.
  13289. * @param worldMatrix is the world matrix of the particle system
  13290. * @param positionToUpdate is the position vector to update with the result
  13291. * @param particle is the particle we are computed the position for
  13292. * @param isLocal defines if the position should be set in local space
  13293. */
  13294. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13295. /**
  13296. * Clones the current emitter and returns a copy of it
  13297. * @returns the new emitter
  13298. */
  13299. clone(): CylinderParticleEmitter;
  13300. /**
  13301. * Called by the GPUParticleSystem to setup the update shader
  13302. * @param effect defines the update shader
  13303. */
  13304. applyToShader(effect: Effect): void;
  13305. /**
  13306. * Returns a string to use to update the GPU particles update shader
  13307. * @returns a string containng the defines string
  13308. */
  13309. getEffectDefines(): string;
  13310. /**
  13311. * Returns the string "CylinderParticleEmitter"
  13312. * @returns a string containing the class name
  13313. */
  13314. getClassName(): string;
  13315. /**
  13316. * Serializes the particle system to a JSON object.
  13317. * @returns the JSON object
  13318. */
  13319. serialize(): any;
  13320. /**
  13321. * Parse properties from a JSON object
  13322. * @param serializationObject defines the JSON object
  13323. */
  13324. parse(serializationObject: any): void;
  13325. }
  13326. /**
  13327. * Particle emitter emitting particles from the inside of a cylinder.
  13328. * It emits the particles randomly between two vectors.
  13329. */
  13330. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13331. /**
  13332. * The min limit of the emission direction.
  13333. */
  13334. direction1: Vector3;
  13335. /**
  13336. * The max limit of the emission direction.
  13337. */
  13338. direction2: Vector3;
  13339. /**
  13340. * Creates a new instance CylinderDirectedParticleEmitter
  13341. * @param radius the radius of the emission cylinder (1 by default)
  13342. * @param height the height of the emission cylinder (1 by default)
  13343. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13344. * @param direction1 the min limit of the emission direction (up vector by default)
  13345. * @param direction2 the max limit of the emission direction (up vector by default)
  13346. */
  13347. constructor(radius?: number, height?: number, radiusRange?: number,
  13348. /**
  13349. * The min limit of the emission direction.
  13350. */
  13351. direction1?: Vector3,
  13352. /**
  13353. * The max limit of the emission direction.
  13354. */
  13355. direction2?: Vector3);
  13356. /**
  13357. * Called by the particle System when the direction is computed for the created particle.
  13358. * @param worldMatrix is the world matrix of the particle system
  13359. * @param directionToUpdate is the direction vector to update with the result
  13360. * @param particle is the particle we are computed the direction for
  13361. */
  13362. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13363. /**
  13364. * Clones the current emitter and returns a copy of it
  13365. * @returns the new emitter
  13366. */
  13367. clone(): CylinderDirectedParticleEmitter;
  13368. /**
  13369. * Called by the GPUParticleSystem to setup the update shader
  13370. * @param effect defines the update shader
  13371. */
  13372. applyToShader(effect: Effect): void;
  13373. /**
  13374. * Returns a string to use to update the GPU particles update shader
  13375. * @returns a string containng the defines string
  13376. */
  13377. getEffectDefines(): string;
  13378. /**
  13379. * Returns the string "CylinderDirectedParticleEmitter"
  13380. * @returns a string containing the class name
  13381. */
  13382. getClassName(): string;
  13383. /**
  13384. * Serializes the particle system to a JSON object.
  13385. * @returns the JSON object
  13386. */
  13387. serialize(): any;
  13388. /**
  13389. * Parse properties from a JSON object
  13390. * @param serializationObject defines the JSON object
  13391. */
  13392. parse(serializationObject: any): void;
  13393. }
  13394. }
  13395. declare module BABYLON {
  13396. /**
  13397. * Particle emitter emitting particles from the inside of a hemisphere.
  13398. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13399. */
  13400. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13401. /**
  13402. * The radius of the emission hemisphere.
  13403. */
  13404. radius: number;
  13405. /**
  13406. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13407. */
  13408. radiusRange: number;
  13409. /**
  13410. * How much to randomize the particle direction [0-1].
  13411. */
  13412. directionRandomizer: number;
  13413. /**
  13414. * Creates a new instance HemisphericParticleEmitter
  13415. * @param radius the radius of the emission hemisphere (1 by default)
  13416. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13417. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13418. */
  13419. constructor(
  13420. /**
  13421. * The radius of the emission hemisphere.
  13422. */
  13423. radius?: number,
  13424. /**
  13425. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13426. */
  13427. radiusRange?: number,
  13428. /**
  13429. * How much to randomize the particle direction [0-1].
  13430. */
  13431. directionRandomizer?: number);
  13432. /**
  13433. * Called by the particle System when the direction is computed for the created particle.
  13434. * @param worldMatrix is the world matrix of the particle system
  13435. * @param directionToUpdate is the direction vector to update with the result
  13436. * @param particle is the particle we are computed the direction for
  13437. * @param isLocal defines if the direction should be set in local space
  13438. */
  13439. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13440. /**
  13441. * Called by the particle System when the position is computed for the created particle.
  13442. * @param worldMatrix is the world matrix of the particle system
  13443. * @param positionToUpdate is the position vector to update with the result
  13444. * @param particle is the particle we are computed the position for
  13445. * @param isLocal defines if the position should be set in local space
  13446. */
  13447. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13448. /**
  13449. * Clones the current emitter and returns a copy of it
  13450. * @returns the new emitter
  13451. */
  13452. clone(): HemisphericParticleEmitter;
  13453. /**
  13454. * Called by the GPUParticleSystem to setup the update shader
  13455. * @param effect defines the update shader
  13456. */
  13457. applyToShader(effect: Effect): void;
  13458. /**
  13459. * Returns a string to use to update the GPU particles update shader
  13460. * @returns a string containng the defines string
  13461. */
  13462. getEffectDefines(): string;
  13463. /**
  13464. * Returns the string "HemisphericParticleEmitter"
  13465. * @returns a string containing the class name
  13466. */
  13467. getClassName(): string;
  13468. /**
  13469. * Serializes the particle system to a JSON object.
  13470. * @returns the JSON object
  13471. */
  13472. serialize(): any;
  13473. /**
  13474. * Parse properties from a JSON object
  13475. * @param serializationObject defines the JSON object
  13476. */
  13477. parse(serializationObject: any): void;
  13478. }
  13479. }
  13480. declare module BABYLON {
  13481. /**
  13482. * Particle emitter emitting particles from a point.
  13483. * It emits the particles randomly between 2 given directions.
  13484. */
  13485. export class PointParticleEmitter implements IParticleEmitterType {
  13486. /**
  13487. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13488. */
  13489. direction1: Vector3;
  13490. /**
  13491. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13492. */
  13493. direction2: Vector3;
  13494. /**
  13495. * Creates a new instance PointParticleEmitter
  13496. */
  13497. constructor();
  13498. /**
  13499. * Called by the particle System when the direction is computed for the created particle.
  13500. * @param worldMatrix is the world matrix of the particle system
  13501. * @param directionToUpdate is the direction vector to update with the result
  13502. * @param particle is the particle we are computed the direction for
  13503. * @param isLocal defines if the direction should be set in local space
  13504. */
  13505. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13506. /**
  13507. * Called by the particle System when the position is computed for the created particle.
  13508. * @param worldMatrix is the world matrix of the particle system
  13509. * @param positionToUpdate is the position vector to update with the result
  13510. * @param particle is the particle we are computed the position for
  13511. * @param isLocal defines if the position should be set in local space
  13512. */
  13513. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13514. /**
  13515. * Clones the current emitter and returns a copy of it
  13516. * @returns the new emitter
  13517. */
  13518. clone(): PointParticleEmitter;
  13519. /**
  13520. * Called by the GPUParticleSystem to setup the update shader
  13521. * @param effect defines the update shader
  13522. */
  13523. applyToShader(effect: Effect): void;
  13524. /**
  13525. * Returns a string to use to update the GPU particles update shader
  13526. * @returns a string containng the defines string
  13527. */
  13528. getEffectDefines(): string;
  13529. /**
  13530. * Returns the string "PointParticleEmitter"
  13531. * @returns a string containing the class name
  13532. */
  13533. getClassName(): string;
  13534. /**
  13535. * Serializes the particle system to a JSON object.
  13536. * @returns the JSON object
  13537. */
  13538. serialize(): any;
  13539. /**
  13540. * Parse properties from a JSON object
  13541. * @param serializationObject defines the JSON object
  13542. */
  13543. parse(serializationObject: any): void;
  13544. }
  13545. }
  13546. declare module BABYLON {
  13547. /**
  13548. * Particle emitter emitting particles from the inside of a sphere.
  13549. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13550. */
  13551. export class SphereParticleEmitter implements IParticleEmitterType {
  13552. /**
  13553. * The radius of the emission sphere.
  13554. */
  13555. radius: number;
  13556. /**
  13557. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13558. */
  13559. radiusRange: number;
  13560. /**
  13561. * How much to randomize the particle direction [0-1].
  13562. */
  13563. directionRandomizer: number;
  13564. /**
  13565. * Creates a new instance SphereParticleEmitter
  13566. * @param radius the radius of the emission sphere (1 by default)
  13567. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13568. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13569. */
  13570. constructor(
  13571. /**
  13572. * The radius of the emission sphere.
  13573. */
  13574. radius?: number,
  13575. /**
  13576. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13577. */
  13578. radiusRange?: number,
  13579. /**
  13580. * How much to randomize the particle direction [0-1].
  13581. */
  13582. directionRandomizer?: number);
  13583. /**
  13584. * Called by the particle System when the direction is computed for the created particle.
  13585. * @param worldMatrix is the world matrix of the particle system
  13586. * @param directionToUpdate is the direction vector to update with the result
  13587. * @param particle is the particle we are computed the direction for
  13588. * @param isLocal defines if the direction should be set in local space
  13589. */
  13590. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13591. /**
  13592. * Called by the particle System when the position is computed for the created particle.
  13593. * @param worldMatrix is the world matrix of the particle system
  13594. * @param positionToUpdate is the position vector to update with the result
  13595. * @param particle is the particle we are computed the position for
  13596. * @param isLocal defines if the position should be set in local space
  13597. */
  13598. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13599. /**
  13600. * Clones the current emitter and returns a copy of it
  13601. * @returns the new emitter
  13602. */
  13603. clone(): SphereParticleEmitter;
  13604. /**
  13605. * Called by the GPUParticleSystem to setup the update shader
  13606. * @param effect defines the update shader
  13607. */
  13608. applyToShader(effect: Effect): void;
  13609. /**
  13610. * Returns a string to use to update the GPU particles update shader
  13611. * @returns a string containng the defines string
  13612. */
  13613. getEffectDefines(): string;
  13614. /**
  13615. * Returns the string "SphereParticleEmitter"
  13616. * @returns a string containing the class name
  13617. */
  13618. getClassName(): string;
  13619. /**
  13620. * Serializes the particle system to a JSON object.
  13621. * @returns the JSON object
  13622. */
  13623. serialize(): any;
  13624. /**
  13625. * Parse properties from a JSON object
  13626. * @param serializationObject defines the JSON object
  13627. */
  13628. parse(serializationObject: any): void;
  13629. }
  13630. /**
  13631. * Particle emitter emitting particles from the inside of a sphere.
  13632. * It emits the particles randomly between two vectors.
  13633. */
  13634. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13635. /**
  13636. * The min limit of the emission direction.
  13637. */
  13638. direction1: Vector3;
  13639. /**
  13640. * The max limit of the emission direction.
  13641. */
  13642. direction2: Vector3;
  13643. /**
  13644. * Creates a new instance SphereDirectedParticleEmitter
  13645. * @param radius the radius of the emission sphere (1 by default)
  13646. * @param direction1 the min limit of the emission direction (up vector by default)
  13647. * @param direction2 the max limit of the emission direction (up vector by default)
  13648. */
  13649. constructor(radius?: number,
  13650. /**
  13651. * The min limit of the emission direction.
  13652. */
  13653. direction1?: Vector3,
  13654. /**
  13655. * The max limit of the emission direction.
  13656. */
  13657. direction2?: Vector3);
  13658. /**
  13659. * Called by the particle System when the direction is computed for the created particle.
  13660. * @param worldMatrix is the world matrix of the particle system
  13661. * @param directionToUpdate is the direction vector to update with the result
  13662. * @param particle is the particle we are computed the direction for
  13663. */
  13664. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13665. /**
  13666. * Clones the current emitter and returns a copy of it
  13667. * @returns the new emitter
  13668. */
  13669. clone(): SphereDirectedParticleEmitter;
  13670. /**
  13671. * Called by the GPUParticleSystem to setup the update shader
  13672. * @param effect defines the update shader
  13673. */
  13674. applyToShader(effect: Effect): void;
  13675. /**
  13676. * Returns a string to use to update the GPU particles update shader
  13677. * @returns a string containng the defines string
  13678. */
  13679. getEffectDefines(): string;
  13680. /**
  13681. * Returns the string "SphereDirectedParticleEmitter"
  13682. * @returns a string containing the class name
  13683. */
  13684. getClassName(): string;
  13685. /**
  13686. * Serializes the particle system to a JSON object.
  13687. * @returns the JSON object
  13688. */
  13689. serialize(): any;
  13690. /**
  13691. * Parse properties from a JSON object
  13692. * @param serializationObject defines the JSON object
  13693. */
  13694. parse(serializationObject: any): void;
  13695. }
  13696. }
  13697. declare module BABYLON {
  13698. /**
  13699. * Particle emitter emitting particles from a custom list of positions.
  13700. */
  13701. export class CustomParticleEmitter implements IParticleEmitterType {
  13702. /**
  13703. * Gets or sets the position generator that will create the inital position of each particle.
  13704. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13705. */
  13706. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13707. /**
  13708. * Gets or sets the destination generator that will create the final destination of each particle.
  13709. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13710. */
  13711. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13712. /**
  13713. * Creates a new instance CustomParticleEmitter
  13714. */
  13715. constructor();
  13716. /**
  13717. * Called by the particle System when the direction is computed for the created particle.
  13718. * @param worldMatrix is the world matrix of the particle system
  13719. * @param directionToUpdate is the direction vector to update with the result
  13720. * @param particle is the particle we are computed the direction for
  13721. * @param isLocal defines if the direction should be set in local space
  13722. */
  13723. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13724. /**
  13725. * Called by the particle System when the position is computed for the created particle.
  13726. * @param worldMatrix is the world matrix of the particle system
  13727. * @param positionToUpdate is the position vector to update with the result
  13728. * @param particle is the particle we are computed the position for
  13729. * @param isLocal defines if the position should be set in local space
  13730. */
  13731. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13732. /**
  13733. * Clones the current emitter and returns a copy of it
  13734. * @returns the new emitter
  13735. */
  13736. clone(): CustomParticleEmitter;
  13737. /**
  13738. * Called by the GPUParticleSystem to setup the update shader
  13739. * @param effect defines the update shader
  13740. */
  13741. applyToShader(effect: Effect): void;
  13742. /**
  13743. * Returns a string to use to update the GPU particles update shader
  13744. * @returns a string containng the defines string
  13745. */
  13746. getEffectDefines(): string;
  13747. /**
  13748. * Returns the string "PointParticleEmitter"
  13749. * @returns a string containing the class name
  13750. */
  13751. getClassName(): string;
  13752. /**
  13753. * Serializes the particle system to a JSON object.
  13754. * @returns the JSON object
  13755. */
  13756. serialize(): any;
  13757. /**
  13758. * Parse properties from a JSON object
  13759. * @param serializationObject defines the JSON object
  13760. */
  13761. parse(serializationObject: any): void;
  13762. }
  13763. }
  13764. declare module BABYLON {
  13765. /**
  13766. * Particle emitter emitting particles from the inside of a box.
  13767. * It emits the particles randomly between 2 given directions.
  13768. */
  13769. export class MeshParticleEmitter implements IParticleEmitterType {
  13770. private _indices;
  13771. private _positions;
  13772. private _normals;
  13773. private _storedNormal;
  13774. private _mesh;
  13775. /**
  13776. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13777. */
  13778. direction1: Vector3;
  13779. /**
  13780. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13781. */
  13782. direction2: Vector3;
  13783. /**
  13784. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13785. */
  13786. useMeshNormalsForDirection: boolean;
  13787. /** Defines the mesh to use as source */
  13788. get mesh(): Nullable<AbstractMesh>;
  13789. set mesh(value: Nullable<AbstractMesh>);
  13790. /**
  13791. * Creates a new instance MeshParticleEmitter
  13792. * @param mesh defines the mesh to use as source
  13793. */
  13794. constructor(mesh?: Nullable<AbstractMesh>);
  13795. /**
  13796. * Called by the particle System when the direction is computed for the created particle.
  13797. * @param worldMatrix is the world matrix of the particle system
  13798. * @param directionToUpdate is the direction vector to update with the result
  13799. * @param particle is the particle we are computed the direction for
  13800. * @param isLocal defines if the direction should be set in local space
  13801. */
  13802. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13803. /**
  13804. * Called by the particle System when the position is computed for the created particle.
  13805. * @param worldMatrix is the world matrix of the particle system
  13806. * @param positionToUpdate is the position vector to update with the result
  13807. * @param particle is the particle we are computed the position for
  13808. * @param isLocal defines if the position should be set in local space
  13809. */
  13810. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13811. /**
  13812. * Clones the current emitter and returns a copy of it
  13813. * @returns the new emitter
  13814. */
  13815. clone(): MeshParticleEmitter;
  13816. /**
  13817. * Called by the GPUParticleSystem to setup the update shader
  13818. * @param effect defines the update shader
  13819. */
  13820. applyToShader(effect: Effect): void;
  13821. /**
  13822. * Returns a string to use to update the GPU particles update shader
  13823. * @returns a string containng the defines string
  13824. */
  13825. getEffectDefines(): string;
  13826. /**
  13827. * Returns the string "BoxParticleEmitter"
  13828. * @returns a string containing the class name
  13829. */
  13830. getClassName(): string;
  13831. /**
  13832. * Serializes the particle system to a JSON object.
  13833. * @returns the JSON object
  13834. */
  13835. serialize(): any;
  13836. /**
  13837. * Parse properties from a JSON object
  13838. * @param serializationObject defines the JSON object
  13839. * @param scene defines the hosting scene
  13840. */
  13841. parse(serializationObject: any, scene: Scene): void;
  13842. }
  13843. }
  13844. declare module BABYLON {
  13845. /**
  13846. * Interface representing a particle system in Babylon.js.
  13847. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13848. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13849. */
  13850. export interface IParticleSystem {
  13851. /**
  13852. * List of animations used by the particle system.
  13853. */
  13854. animations: Animation[];
  13855. /**
  13856. * The id of the Particle system.
  13857. */
  13858. id: string;
  13859. /**
  13860. * The name of the Particle system.
  13861. */
  13862. name: string;
  13863. /**
  13864. * The emitter represents the Mesh or position we are attaching the particle system to.
  13865. */
  13866. emitter: Nullable<AbstractMesh | Vector3>;
  13867. /**
  13868. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13869. */
  13870. isBillboardBased: boolean;
  13871. /**
  13872. * The rendering group used by the Particle system to chose when to render.
  13873. */
  13874. renderingGroupId: number;
  13875. /**
  13876. * The layer mask we are rendering the particles through.
  13877. */
  13878. layerMask: number;
  13879. /**
  13880. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13881. */
  13882. updateSpeed: number;
  13883. /**
  13884. * The amount of time the particle system is running (depends of the overall update speed).
  13885. */
  13886. targetStopDuration: number;
  13887. /**
  13888. * The texture used to render each particle. (this can be a spritesheet)
  13889. */
  13890. particleTexture: Nullable<Texture>;
  13891. /**
  13892. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13893. */
  13894. blendMode: number;
  13895. /**
  13896. * Minimum life time of emitting particles.
  13897. */
  13898. minLifeTime: number;
  13899. /**
  13900. * Maximum life time of emitting particles.
  13901. */
  13902. maxLifeTime: number;
  13903. /**
  13904. * Minimum Size of emitting particles.
  13905. */
  13906. minSize: number;
  13907. /**
  13908. * Maximum Size of emitting particles.
  13909. */
  13910. maxSize: number;
  13911. /**
  13912. * Minimum scale of emitting particles on X axis.
  13913. */
  13914. minScaleX: number;
  13915. /**
  13916. * Maximum scale of emitting particles on X axis.
  13917. */
  13918. maxScaleX: number;
  13919. /**
  13920. * Minimum scale of emitting particles on Y axis.
  13921. */
  13922. minScaleY: number;
  13923. /**
  13924. * Maximum scale of emitting particles on Y axis.
  13925. */
  13926. maxScaleY: number;
  13927. /**
  13928. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13929. */
  13930. color1: Color4;
  13931. /**
  13932. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13933. */
  13934. color2: Color4;
  13935. /**
  13936. * Color the particle will have at the end of its lifetime.
  13937. */
  13938. colorDead: Color4;
  13939. /**
  13940. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13941. */
  13942. emitRate: number;
  13943. /**
  13944. * You can use gravity if you want to give an orientation to your particles.
  13945. */
  13946. gravity: Vector3;
  13947. /**
  13948. * Minimum power of emitting particles.
  13949. */
  13950. minEmitPower: number;
  13951. /**
  13952. * Maximum power of emitting particles.
  13953. */
  13954. maxEmitPower: number;
  13955. /**
  13956. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13957. */
  13958. minAngularSpeed: number;
  13959. /**
  13960. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13961. */
  13962. maxAngularSpeed: number;
  13963. /**
  13964. * Gets or sets the minimal initial rotation in radians.
  13965. */
  13966. minInitialRotation: number;
  13967. /**
  13968. * Gets or sets the maximal initial rotation in radians.
  13969. */
  13970. maxInitialRotation: number;
  13971. /**
  13972. * The particle emitter type defines the emitter used by the particle system.
  13973. * It can be for example box, sphere, or cone...
  13974. */
  13975. particleEmitterType: Nullable<IParticleEmitterType>;
  13976. /**
  13977. * Defines the delay in milliseconds before starting the system (0 by default)
  13978. */
  13979. startDelay: number;
  13980. /**
  13981. * 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
  13982. */
  13983. preWarmCycles: number;
  13984. /**
  13985. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13986. */
  13987. preWarmStepOffset: number;
  13988. /**
  13989. * 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)
  13990. */
  13991. spriteCellChangeSpeed: number;
  13992. /**
  13993. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13994. */
  13995. startSpriteCellID: number;
  13996. /**
  13997. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13998. */
  13999. endSpriteCellID: number;
  14000. /**
  14001. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14002. */
  14003. spriteCellWidth: number;
  14004. /**
  14005. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14006. */
  14007. spriteCellHeight: number;
  14008. /**
  14009. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14010. */
  14011. spriteRandomStartCell: boolean;
  14012. /**
  14013. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14014. */
  14015. isAnimationSheetEnabled: boolean;
  14016. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14017. translationPivot: Vector2;
  14018. /**
  14019. * Gets or sets a texture used to add random noise to particle positions
  14020. */
  14021. noiseTexture: Nullable<BaseTexture>;
  14022. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14023. noiseStrength: Vector3;
  14024. /**
  14025. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14026. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14027. */
  14028. billboardMode: number;
  14029. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14030. limitVelocityDamping: number;
  14031. /**
  14032. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14033. */
  14034. beginAnimationOnStart: boolean;
  14035. /**
  14036. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14037. */
  14038. beginAnimationFrom: number;
  14039. /**
  14040. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14041. */
  14042. beginAnimationTo: number;
  14043. /**
  14044. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14045. */
  14046. beginAnimationLoop: boolean;
  14047. /**
  14048. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14049. */
  14050. disposeOnStop: boolean;
  14051. /**
  14052. * Specifies if the particles are updated in emitter local space or world space
  14053. */
  14054. isLocal: boolean;
  14055. /** Snippet ID if the particle system was created from the snippet server */
  14056. snippetId: string;
  14057. /**
  14058. * Gets the maximum number of particles active at the same time.
  14059. * @returns The max number of active particles.
  14060. */
  14061. getCapacity(): number;
  14062. /**
  14063. * Gets the number of particles active at the same time.
  14064. * @returns The number of active particles.
  14065. */
  14066. getActiveCount(): number;
  14067. /**
  14068. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14069. * @returns True if it has been started, otherwise false.
  14070. */
  14071. isStarted(): boolean;
  14072. /**
  14073. * Animates the particle system for this frame.
  14074. */
  14075. animate(): void;
  14076. /**
  14077. * Renders the particle system in its current state.
  14078. * @returns the current number of particles
  14079. */
  14080. render(): number;
  14081. /**
  14082. * Dispose the particle system and frees its associated resources.
  14083. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14084. */
  14085. dispose(disposeTexture?: boolean): void;
  14086. /**
  14087. * An event triggered when the system is disposed
  14088. */
  14089. onDisposeObservable: Observable<IParticleSystem>;
  14090. /**
  14091. * Clones the particle system.
  14092. * @param name The name of the cloned object
  14093. * @param newEmitter The new emitter to use
  14094. * @returns the cloned particle system
  14095. */
  14096. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14097. /**
  14098. * Serializes the particle system to a JSON object
  14099. * @param serializeTexture defines if the texture must be serialized as well
  14100. * @returns the JSON object
  14101. */
  14102. serialize(serializeTexture: boolean): any;
  14103. /**
  14104. * Rebuild the particle system
  14105. */
  14106. rebuild(): void;
  14107. /** Force the system to rebuild all gradients that need to be resync */
  14108. forceRefreshGradients(): void;
  14109. /**
  14110. * Starts the particle system and begins to emit
  14111. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14112. */
  14113. start(delay?: number): void;
  14114. /**
  14115. * Stops the particle system.
  14116. */
  14117. stop(): void;
  14118. /**
  14119. * Remove all active particles
  14120. */
  14121. reset(): void;
  14122. /**
  14123. * Gets a boolean indicating that the system is stopping
  14124. * @returns true if the system is currently stopping
  14125. */
  14126. isStopping(): boolean;
  14127. /**
  14128. * Is this system ready to be used/rendered
  14129. * @return true if the system is ready
  14130. */
  14131. isReady(): boolean;
  14132. /**
  14133. * Returns the string "ParticleSystem"
  14134. * @returns a string containing the class name
  14135. */
  14136. getClassName(): string;
  14137. /**
  14138. * Gets the custom effect used to render the particles
  14139. * @param blendMode Blend mode for which the effect should be retrieved
  14140. * @returns The effect
  14141. */
  14142. getCustomEffect(blendMode: number): Nullable<Effect>;
  14143. /**
  14144. * Sets the custom effect used to render the particles
  14145. * @param effect The effect to set
  14146. * @param blendMode Blend mode for which the effect should be set
  14147. */
  14148. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14149. /**
  14150. * Fill the defines array according to the current settings of the particle system
  14151. * @param defines Array to be updated
  14152. * @param blendMode blend mode to take into account when updating the array
  14153. */
  14154. fillDefines(defines: Array<string>, blendMode: number): void;
  14155. /**
  14156. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14157. * @param uniforms Uniforms array to fill
  14158. * @param attributes Attributes array to fill
  14159. * @param samplers Samplers array to fill
  14160. */
  14161. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14162. /**
  14163. * Observable that will be called just before the particles are drawn
  14164. */
  14165. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14166. /**
  14167. * Gets the name of the particle vertex shader
  14168. */
  14169. vertexShaderName: string;
  14170. /**
  14171. * Adds a new color gradient
  14172. * @param gradient defines the gradient to use (between 0 and 1)
  14173. * @param color1 defines the color to affect to the specified gradient
  14174. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14175. * @returns the current particle system
  14176. */
  14177. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14178. /**
  14179. * Remove a specific color gradient
  14180. * @param gradient defines the gradient to remove
  14181. * @returns the current particle system
  14182. */
  14183. removeColorGradient(gradient: number): IParticleSystem;
  14184. /**
  14185. * Adds a new size gradient
  14186. * @param gradient defines the gradient to use (between 0 and 1)
  14187. * @param factor defines the size factor to affect to the specified gradient
  14188. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14189. * @returns the current particle system
  14190. */
  14191. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14192. /**
  14193. * Remove a specific size gradient
  14194. * @param gradient defines the gradient to remove
  14195. * @returns the current particle system
  14196. */
  14197. removeSizeGradient(gradient: number): IParticleSystem;
  14198. /**
  14199. * Gets the current list of color gradients.
  14200. * You must use addColorGradient and removeColorGradient to udpate this list
  14201. * @returns the list of color gradients
  14202. */
  14203. getColorGradients(): Nullable<Array<ColorGradient>>;
  14204. /**
  14205. * Gets the current list of size gradients.
  14206. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14207. * @returns the list of size gradients
  14208. */
  14209. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14210. /**
  14211. * Gets the current list of angular speed gradients.
  14212. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14213. * @returns the list of angular speed gradients
  14214. */
  14215. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14216. /**
  14217. * Adds a new angular speed gradient
  14218. * @param gradient defines the gradient to use (between 0 and 1)
  14219. * @param factor defines the angular speed to affect to the specified gradient
  14220. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14221. * @returns the current particle system
  14222. */
  14223. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14224. /**
  14225. * Remove a specific angular speed gradient
  14226. * @param gradient defines the gradient to remove
  14227. * @returns the current particle system
  14228. */
  14229. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14230. /**
  14231. * Gets the current list of velocity gradients.
  14232. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14233. * @returns the list of velocity gradients
  14234. */
  14235. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14236. /**
  14237. * Adds a new velocity gradient
  14238. * @param gradient defines the gradient to use (between 0 and 1)
  14239. * @param factor defines the velocity to affect to the specified gradient
  14240. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14241. * @returns the current particle system
  14242. */
  14243. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14244. /**
  14245. * Remove a specific velocity gradient
  14246. * @param gradient defines the gradient to remove
  14247. * @returns the current particle system
  14248. */
  14249. removeVelocityGradient(gradient: number): IParticleSystem;
  14250. /**
  14251. * Gets the current list of limit velocity gradients.
  14252. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14253. * @returns the list of limit velocity gradients
  14254. */
  14255. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14256. /**
  14257. * Adds a new limit velocity gradient
  14258. * @param gradient defines the gradient to use (between 0 and 1)
  14259. * @param factor defines the limit velocity to affect to the specified gradient
  14260. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14261. * @returns the current particle system
  14262. */
  14263. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14264. /**
  14265. * Remove a specific limit velocity gradient
  14266. * @param gradient defines the gradient to remove
  14267. * @returns the current particle system
  14268. */
  14269. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14270. /**
  14271. * Adds a new drag gradient
  14272. * @param gradient defines the gradient to use (between 0 and 1)
  14273. * @param factor defines the drag to affect to the specified gradient
  14274. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14275. * @returns the current particle system
  14276. */
  14277. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14278. /**
  14279. * Remove a specific drag gradient
  14280. * @param gradient defines the gradient to remove
  14281. * @returns the current particle system
  14282. */
  14283. removeDragGradient(gradient: number): IParticleSystem;
  14284. /**
  14285. * Gets the current list of drag gradients.
  14286. * You must use addDragGradient and removeDragGradient to udpate this list
  14287. * @returns the list of drag gradients
  14288. */
  14289. getDragGradients(): Nullable<Array<FactorGradient>>;
  14290. /**
  14291. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14292. * @param gradient defines the gradient to use (between 0 and 1)
  14293. * @param factor defines the emit rate to affect to the specified gradient
  14294. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14295. * @returns the current particle system
  14296. */
  14297. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14298. /**
  14299. * Remove a specific emit rate gradient
  14300. * @param gradient defines the gradient to remove
  14301. * @returns the current particle system
  14302. */
  14303. removeEmitRateGradient(gradient: number): IParticleSystem;
  14304. /**
  14305. * Gets the current list of emit rate gradients.
  14306. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14307. * @returns the list of emit rate gradients
  14308. */
  14309. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14310. /**
  14311. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14312. * @param gradient defines the gradient to use (between 0 and 1)
  14313. * @param factor defines the start size to affect to the specified gradient
  14314. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14315. * @returns the current particle system
  14316. */
  14317. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14318. /**
  14319. * Remove a specific start size gradient
  14320. * @param gradient defines the gradient to remove
  14321. * @returns the current particle system
  14322. */
  14323. removeStartSizeGradient(gradient: number): IParticleSystem;
  14324. /**
  14325. * Gets the current list of start size gradients.
  14326. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14327. * @returns the list of start size gradients
  14328. */
  14329. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14330. /**
  14331. * Adds a new life time gradient
  14332. * @param gradient defines the gradient to use (between 0 and 1)
  14333. * @param factor defines the life time factor to affect to the specified gradient
  14334. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14335. * @returns the current particle system
  14336. */
  14337. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14338. /**
  14339. * Remove a specific life time gradient
  14340. * @param gradient defines the gradient to remove
  14341. * @returns the current particle system
  14342. */
  14343. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14344. /**
  14345. * Gets the current list of life time gradients.
  14346. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14347. * @returns the list of life time gradients
  14348. */
  14349. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14350. /**
  14351. * Gets the current list of color gradients.
  14352. * You must use addColorGradient and removeColorGradient to udpate this list
  14353. * @returns the list of color gradients
  14354. */
  14355. getColorGradients(): Nullable<Array<ColorGradient>>;
  14356. /**
  14357. * Adds a new ramp gradient used to remap particle colors
  14358. * @param gradient defines the gradient to use (between 0 and 1)
  14359. * @param color defines the color to affect to the specified gradient
  14360. * @returns the current particle system
  14361. */
  14362. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14363. /**
  14364. * Gets the current list of ramp gradients.
  14365. * You must use addRampGradient and removeRampGradient to udpate this list
  14366. * @returns the list of ramp gradients
  14367. */
  14368. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14369. /** Gets or sets a boolean indicating that ramp gradients must be used
  14370. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14371. */
  14372. useRampGradients: boolean;
  14373. /**
  14374. * Adds a new color remap gradient
  14375. * @param gradient defines the gradient to use (between 0 and 1)
  14376. * @param min defines the color remap minimal range
  14377. * @param max defines the color remap maximal range
  14378. * @returns the current particle system
  14379. */
  14380. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14381. /**
  14382. * Gets the current list of color remap gradients.
  14383. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14384. * @returns the list of color remap gradients
  14385. */
  14386. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14387. /**
  14388. * Adds a new alpha remap gradient
  14389. * @param gradient defines the gradient to use (between 0 and 1)
  14390. * @param min defines the alpha remap minimal range
  14391. * @param max defines the alpha remap maximal range
  14392. * @returns the current particle system
  14393. */
  14394. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14395. /**
  14396. * Gets the current list of alpha remap gradients.
  14397. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14398. * @returns the list of alpha remap gradients
  14399. */
  14400. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14401. /**
  14402. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14403. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14404. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14405. * @returns the emitter
  14406. */
  14407. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14408. /**
  14409. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14410. * @param radius The radius of the hemisphere to emit from
  14411. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14412. * @returns the emitter
  14413. */
  14414. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14415. /**
  14416. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14417. * @param radius The radius of the sphere to emit from
  14418. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14419. * @returns the emitter
  14420. */
  14421. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14422. /**
  14423. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14424. * @param radius The radius of the sphere to emit from
  14425. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14426. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14427. * @returns the emitter
  14428. */
  14429. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14430. /**
  14431. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14432. * @param radius The radius of the emission cylinder
  14433. * @param height The height of the emission cylinder
  14434. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14435. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14436. * @returns the emitter
  14437. */
  14438. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14439. /**
  14440. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14441. * @param radius The radius of the cylinder to emit from
  14442. * @param height The height of the emission cylinder
  14443. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14444. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14445. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14446. * @returns the emitter
  14447. */
  14448. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14449. /**
  14450. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14451. * @param radius The radius of the cone to emit from
  14452. * @param angle The base angle of the cone
  14453. * @returns the emitter
  14454. */
  14455. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14456. /**
  14457. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14458. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14459. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14460. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14461. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14462. * @returns the emitter
  14463. */
  14464. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14465. /**
  14466. * Get hosting scene
  14467. * @returns the scene
  14468. */
  14469. getScene(): Scene;
  14470. }
  14471. }
  14472. declare module BABYLON {
  14473. /**
  14474. * 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.
  14475. * @see https://doc.babylonjs.com/how_to/transformnode
  14476. */
  14477. export class TransformNode extends Node {
  14478. /**
  14479. * Object will not rotate to face the camera
  14480. */
  14481. static BILLBOARDMODE_NONE: number;
  14482. /**
  14483. * Object will rotate to face the camera but only on the x axis
  14484. */
  14485. static BILLBOARDMODE_X: number;
  14486. /**
  14487. * Object will rotate to face the camera but only on the y axis
  14488. */
  14489. static BILLBOARDMODE_Y: number;
  14490. /**
  14491. * Object will rotate to face the camera but only on the z axis
  14492. */
  14493. static BILLBOARDMODE_Z: number;
  14494. /**
  14495. * Object will rotate to face the camera
  14496. */
  14497. static BILLBOARDMODE_ALL: number;
  14498. /**
  14499. * Object will rotate to face the camera's position instead of orientation
  14500. */
  14501. static BILLBOARDMODE_USE_POSITION: number;
  14502. private _forward;
  14503. private _forwardInverted;
  14504. private _up;
  14505. private _right;
  14506. private _rightInverted;
  14507. private _position;
  14508. private _rotation;
  14509. private _rotationQuaternion;
  14510. protected _scaling: Vector3;
  14511. protected _isDirty: boolean;
  14512. private _transformToBoneReferal;
  14513. private _isAbsoluteSynced;
  14514. private _billboardMode;
  14515. /**
  14516. * Gets or sets the billboard mode. Default is 0.
  14517. *
  14518. * | Value | Type | Description |
  14519. * | --- | --- | --- |
  14520. * | 0 | BILLBOARDMODE_NONE | |
  14521. * | 1 | BILLBOARDMODE_X | |
  14522. * | 2 | BILLBOARDMODE_Y | |
  14523. * | 4 | BILLBOARDMODE_Z | |
  14524. * | 7 | BILLBOARDMODE_ALL | |
  14525. *
  14526. */
  14527. get billboardMode(): number;
  14528. set billboardMode(value: number);
  14529. private _preserveParentRotationForBillboard;
  14530. /**
  14531. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14532. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14533. */
  14534. get preserveParentRotationForBillboard(): boolean;
  14535. set preserveParentRotationForBillboard(value: boolean);
  14536. /**
  14537. * 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
  14538. */
  14539. scalingDeterminant: number;
  14540. private _infiniteDistance;
  14541. /**
  14542. * Gets or sets the distance of the object to max, often used by skybox
  14543. */
  14544. get infiniteDistance(): boolean;
  14545. set infiniteDistance(value: boolean);
  14546. /**
  14547. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14548. * By default the system will update normals to compensate
  14549. */
  14550. ignoreNonUniformScaling: boolean;
  14551. /**
  14552. * 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
  14553. */
  14554. reIntegrateRotationIntoRotationQuaternion: boolean;
  14555. /** @hidden */
  14556. _poseMatrix: Nullable<Matrix>;
  14557. /** @hidden */
  14558. _localMatrix: Matrix;
  14559. private _usePivotMatrix;
  14560. private _absolutePosition;
  14561. private _absoluteScaling;
  14562. private _absoluteRotationQuaternion;
  14563. private _pivotMatrix;
  14564. private _pivotMatrixInverse;
  14565. protected _postMultiplyPivotMatrix: boolean;
  14566. protected _isWorldMatrixFrozen: boolean;
  14567. /** @hidden */
  14568. _indexInSceneTransformNodesArray: number;
  14569. /**
  14570. * An event triggered after the world matrix is updated
  14571. */
  14572. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14573. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14574. /**
  14575. * Gets a string identifying the name of the class
  14576. * @returns "TransformNode" string
  14577. */
  14578. getClassName(): string;
  14579. /**
  14580. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14581. */
  14582. get position(): Vector3;
  14583. set position(newPosition: Vector3);
  14584. /**
  14585. * 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)).
  14586. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14587. */
  14588. get rotation(): Vector3;
  14589. set rotation(newRotation: Vector3);
  14590. /**
  14591. * 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)).
  14592. */
  14593. get scaling(): Vector3;
  14594. set scaling(newScaling: Vector3);
  14595. /**
  14596. * 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).
  14597. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14598. */
  14599. get rotationQuaternion(): Nullable<Quaternion>;
  14600. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14601. /**
  14602. * The forward direction of that transform in world space.
  14603. */
  14604. get forward(): Vector3;
  14605. /**
  14606. * The up direction of that transform in world space.
  14607. */
  14608. get up(): Vector3;
  14609. /**
  14610. * The right direction of that transform in world space.
  14611. */
  14612. get right(): Vector3;
  14613. /**
  14614. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14615. * @param matrix the matrix to copy the pose from
  14616. * @returns this TransformNode.
  14617. */
  14618. updatePoseMatrix(matrix: Matrix): TransformNode;
  14619. /**
  14620. * Returns the mesh Pose matrix.
  14621. * @returns the pose matrix
  14622. */
  14623. getPoseMatrix(): Matrix;
  14624. /** @hidden */
  14625. _isSynchronized(): boolean;
  14626. /** @hidden */
  14627. _initCache(): void;
  14628. /**
  14629. * Flag the transform node as dirty (Forcing it to update everything)
  14630. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14631. * @returns this transform node
  14632. */
  14633. markAsDirty(property: string): TransformNode;
  14634. /**
  14635. * Returns the current mesh absolute position.
  14636. * Returns a Vector3.
  14637. */
  14638. get absolutePosition(): Vector3;
  14639. /**
  14640. * Returns the current mesh absolute scaling.
  14641. * Returns a Vector3.
  14642. */
  14643. get absoluteScaling(): Vector3;
  14644. /**
  14645. * Returns the current mesh absolute rotation.
  14646. * Returns a Quaternion.
  14647. */
  14648. get absoluteRotationQuaternion(): Quaternion;
  14649. /**
  14650. * Sets a new matrix to apply before all other transformation
  14651. * @param matrix defines the transform matrix
  14652. * @returns the current TransformNode
  14653. */
  14654. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14655. /**
  14656. * Sets a new pivot matrix to the current node
  14657. * @param matrix defines the new pivot matrix to use
  14658. * @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
  14659. * @returns the current TransformNode
  14660. */
  14661. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14662. /**
  14663. * Returns the mesh pivot matrix.
  14664. * Default : Identity.
  14665. * @returns the matrix
  14666. */
  14667. getPivotMatrix(): Matrix;
  14668. /**
  14669. * Instantiate (when possible) or clone that node with its hierarchy
  14670. * @param newParent defines the new parent to use for the instance (or clone)
  14671. * @param options defines options to configure how copy is done
  14672. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14673. * @returns an instance (or a clone) of the current node with its hiearchy
  14674. */
  14675. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14676. doNotInstantiate: boolean;
  14677. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14678. /**
  14679. * Prevents the World matrix to be computed any longer
  14680. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14681. * @returns the TransformNode.
  14682. */
  14683. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14684. /**
  14685. * Allows back the World matrix computation.
  14686. * @returns the TransformNode.
  14687. */
  14688. unfreezeWorldMatrix(): this;
  14689. /**
  14690. * True if the World matrix has been frozen.
  14691. */
  14692. get isWorldMatrixFrozen(): boolean;
  14693. /**
  14694. * Retuns the mesh absolute position in the World.
  14695. * @returns a Vector3.
  14696. */
  14697. getAbsolutePosition(): Vector3;
  14698. /**
  14699. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14700. * @param absolutePosition the absolute position to set
  14701. * @returns the TransformNode.
  14702. */
  14703. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14704. /**
  14705. * Sets the mesh position in its local space.
  14706. * @param vector3 the position to set in localspace
  14707. * @returns the TransformNode.
  14708. */
  14709. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14710. /**
  14711. * Returns the mesh position in the local space from the current World matrix values.
  14712. * @returns a new Vector3.
  14713. */
  14714. getPositionExpressedInLocalSpace(): Vector3;
  14715. /**
  14716. * Translates the mesh along the passed Vector3 in its local space.
  14717. * @param vector3 the distance to translate in localspace
  14718. * @returns the TransformNode.
  14719. */
  14720. locallyTranslate(vector3: Vector3): TransformNode;
  14721. private static _lookAtVectorCache;
  14722. /**
  14723. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14724. * @param targetPoint the position (must be in same space as current mesh) to look at
  14725. * @param yawCor optional yaw (y-axis) correction in radians
  14726. * @param pitchCor optional pitch (x-axis) correction in radians
  14727. * @param rollCor optional roll (z-axis) correction in radians
  14728. * @param space the choosen space of the target
  14729. * @returns the TransformNode.
  14730. */
  14731. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14732. /**
  14733. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14734. * This Vector3 is expressed in the World space.
  14735. * @param localAxis axis to rotate
  14736. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14737. */
  14738. getDirection(localAxis: Vector3): Vector3;
  14739. /**
  14740. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14741. * localAxis is expressed in the mesh local space.
  14742. * result is computed in the Wordl space from the mesh World matrix.
  14743. * @param localAxis axis to rotate
  14744. * @param result the resulting transformnode
  14745. * @returns this TransformNode.
  14746. */
  14747. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14748. /**
  14749. * Sets this transform node rotation to the given local axis.
  14750. * @param localAxis the axis in local space
  14751. * @param yawCor optional yaw (y-axis) correction in radians
  14752. * @param pitchCor optional pitch (x-axis) correction in radians
  14753. * @param rollCor optional roll (z-axis) correction in radians
  14754. * @returns this TransformNode
  14755. */
  14756. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14757. /**
  14758. * Sets a new pivot point to the current node
  14759. * @param point defines the new pivot point to use
  14760. * @param space defines if the point is in world or local space (local by default)
  14761. * @returns the current TransformNode
  14762. */
  14763. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14764. /**
  14765. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14766. * @returns the pivot point
  14767. */
  14768. getPivotPoint(): Vector3;
  14769. /**
  14770. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14771. * @param result the vector3 to store the result
  14772. * @returns this TransformNode.
  14773. */
  14774. getPivotPointToRef(result: Vector3): TransformNode;
  14775. /**
  14776. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14777. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14778. */
  14779. getAbsolutePivotPoint(): Vector3;
  14780. /**
  14781. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14782. * @param result vector3 to store the result
  14783. * @returns this TransformNode.
  14784. */
  14785. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14786. /**
  14787. * Defines the passed node as the parent of the current node.
  14788. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14789. * @see https://doc.babylonjs.com/how_to/parenting
  14790. * @param node the node ot set as the parent
  14791. * @returns this TransformNode.
  14792. */
  14793. setParent(node: Nullable<Node>): TransformNode;
  14794. private _nonUniformScaling;
  14795. /**
  14796. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14797. */
  14798. get nonUniformScaling(): boolean;
  14799. /** @hidden */
  14800. _updateNonUniformScalingState(value: boolean): boolean;
  14801. /**
  14802. * Attach the current TransformNode to another TransformNode associated with a bone
  14803. * @param bone Bone affecting the TransformNode
  14804. * @param affectedTransformNode TransformNode associated with the bone
  14805. * @returns this object
  14806. */
  14807. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14808. /**
  14809. * Detach the transform node if its associated with a bone
  14810. * @returns this object
  14811. */
  14812. detachFromBone(): TransformNode;
  14813. private static _rotationAxisCache;
  14814. /**
  14815. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14816. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14817. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14818. * The passed axis is also normalized.
  14819. * @param axis the axis to rotate around
  14820. * @param amount the amount to rotate in radians
  14821. * @param space Space to rotate in (Default: local)
  14822. * @returns the TransformNode.
  14823. */
  14824. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14825. /**
  14826. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14827. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14828. * The passed axis is also normalized. .
  14829. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14830. * @param point the point to rotate around
  14831. * @param axis the axis to rotate around
  14832. * @param amount the amount to rotate in radians
  14833. * @returns the TransformNode
  14834. */
  14835. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14836. /**
  14837. * Translates the mesh along the axis vector for the passed distance in the given space.
  14838. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14839. * @param axis the axis to translate in
  14840. * @param distance the distance to translate
  14841. * @param space Space to rotate in (Default: local)
  14842. * @returns the TransformNode.
  14843. */
  14844. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14845. /**
  14846. * Adds a rotation step to the mesh current rotation.
  14847. * x, y, z are Euler angles expressed in radians.
  14848. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14849. * This means this rotation is made in the mesh local space only.
  14850. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14851. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14852. * ```javascript
  14853. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14854. * ```
  14855. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14856. * 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.
  14857. * @param x Rotation to add
  14858. * @param y Rotation to add
  14859. * @param z Rotation to add
  14860. * @returns the TransformNode.
  14861. */
  14862. addRotation(x: number, y: number, z: number): TransformNode;
  14863. /**
  14864. * @hidden
  14865. */
  14866. protected _getEffectiveParent(): Nullable<Node>;
  14867. /**
  14868. * Computes the world matrix of the node
  14869. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14870. * @returns the world matrix
  14871. */
  14872. computeWorldMatrix(force?: boolean): Matrix;
  14873. /**
  14874. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14875. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14876. */
  14877. resetLocalMatrix(independentOfChildren?: boolean): void;
  14878. protected _afterComputeWorldMatrix(): void;
  14879. /**
  14880. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14881. * @param func callback function to add
  14882. *
  14883. * @returns the TransformNode.
  14884. */
  14885. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14886. /**
  14887. * Removes a registered callback function.
  14888. * @param func callback function to remove
  14889. * @returns the TransformNode.
  14890. */
  14891. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14892. /**
  14893. * Gets the position of the current mesh in camera space
  14894. * @param camera defines the camera to use
  14895. * @returns a position
  14896. */
  14897. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14898. /**
  14899. * Returns the distance from the mesh to the active camera
  14900. * @param camera defines the camera to use
  14901. * @returns the distance
  14902. */
  14903. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14904. /**
  14905. * Clone the current transform node
  14906. * @param name Name of the new clone
  14907. * @param newParent New parent for the clone
  14908. * @param doNotCloneChildren Do not clone children hierarchy
  14909. * @returns the new transform node
  14910. */
  14911. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14912. /**
  14913. * Serializes the objects information.
  14914. * @param currentSerializationObject defines the object to serialize in
  14915. * @returns the serialized object
  14916. */
  14917. serialize(currentSerializationObject?: any): any;
  14918. /**
  14919. * Returns a new TransformNode object parsed from the source provided.
  14920. * @param parsedTransformNode is the source.
  14921. * @param scene the scne the object belongs to
  14922. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14923. * @returns a new TransformNode object parsed from the source provided.
  14924. */
  14925. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14926. /**
  14927. * Get all child-transformNodes of this node
  14928. * @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
  14929. * @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
  14930. * @returns an array of TransformNode
  14931. */
  14932. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14933. /**
  14934. * Releases resources associated with this transform node.
  14935. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14936. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14937. */
  14938. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14939. /**
  14940. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14941. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14942. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14943. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14944. * @returns the current mesh
  14945. */
  14946. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14947. private _syncAbsoluteScalingAndRotation;
  14948. }
  14949. }
  14950. declare module BABYLON {
  14951. /**
  14952. * Class used to override all child animations of a given target
  14953. */
  14954. export class AnimationPropertiesOverride {
  14955. /**
  14956. * Gets or sets a value indicating if animation blending must be used
  14957. */
  14958. enableBlending: boolean;
  14959. /**
  14960. * Gets or sets the blending speed to use when enableBlending is true
  14961. */
  14962. blendingSpeed: number;
  14963. /**
  14964. * Gets or sets the default loop mode to use
  14965. */
  14966. loopMode: number;
  14967. }
  14968. }
  14969. declare module BABYLON {
  14970. /**
  14971. * Class used to store bone information
  14972. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14973. */
  14974. export class Bone extends Node {
  14975. /**
  14976. * defines the bone name
  14977. */
  14978. name: string;
  14979. private static _tmpVecs;
  14980. private static _tmpQuat;
  14981. private static _tmpMats;
  14982. /**
  14983. * Gets the list of child bones
  14984. */
  14985. children: Bone[];
  14986. /** Gets the animations associated with this bone */
  14987. animations: Animation[];
  14988. /**
  14989. * Gets or sets bone length
  14990. */
  14991. length: number;
  14992. /**
  14993. * @hidden Internal only
  14994. * Set this value to map this bone to a different index in the transform matrices
  14995. * Set this value to -1 to exclude the bone from the transform matrices
  14996. */
  14997. _index: Nullable<number>;
  14998. private _skeleton;
  14999. private _localMatrix;
  15000. private _restPose;
  15001. private _baseMatrix;
  15002. private _absoluteTransform;
  15003. private _invertedAbsoluteTransform;
  15004. private _parent;
  15005. private _scalingDeterminant;
  15006. private _worldTransform;
  15007. private _localScaling;
  15008. private _localRotation;
  15009. private _localPosition;
  15010. private _needToDecompose;
  15011. private _needToCompose;
  15012. /** @hidden */
  15013. _linkedTransformNode: Nullable<TransformNode>;
  15014. /** @hidden */
  15015. _waitingTransformNodeId: Nullable<string>;
  15016. /** @hidden */
  15017. get _matrix(): Matrix;
  15018. /** @hidden */
  15019. set _matrix(value: Matrix);
  15020. /**
  15021. * Create a new bone
  15022. * @param name defines the bone name
  15023. * @param skeleton defines the parent skeleton
  15024. * @param parentBone defines the parent (can be null if the bone is the root)
  15025. * @param localMatrix defines the local matrix
  15026. * @param restPose defines the rest pose matrix
  15027. * @param baseMatrix defines the base matrix
  15028. * @param index defines index of the bone in the hiearchy
  15029. */
  15030. constructor(
  15031. /**
  15032. * defines the bone name
  15033. */
  15034. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15035. /**
  15036. * Gets the current object class name.
  15037. * @return the class name
  15038. */
  15039. getClassName(): string;
  15040. /**
  15041. * Gets the parent skeleton
  15042. * @returns a skeleton
  15043. */
  15044. getSkeleton(): Skeleton;
  15045. /**
  15046. * Gets parent bone
  15047. * @returns a bone or null if the bone is the root of the bone hierarchy
  15048. */
  15049. getParent(): Nullable<Bone>;
  15050. /**
  15051. * Returns an array containing the root bones
  15052. * @returns an array containing the root bones
  15053. */
  15054. getChildren(): Array<Bone>;
  15055. /**
  15056. * Gets the node index in matrix array generated for rendering
  15057. * @returns the node index
  15058. */
  15059. getIndex(): number;
  15060. /**
  15061. * Sets the parent bone
  15062. * @param parent defines the parent (can be null if the bone is the root)
  15063. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15064. */
  15065. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15066. /**
  15067. * Gets the local matrix
  15068. * @returns a matrix
  15069. */
  15070. getLocalMatrix(): Matrix;
  15071. /**
  15072. * Gets the base matrix (initial matrix which remains unchanged)
  15073. * @returns a matrix
  15074. */
  15075. getBaseMatrix(): Matrix;
  15076. /**
  15077. * Gets the rest pose matrix
  15078. * @returns a matrix
  15079. */
  15080. getRestPose(): Matrix;
  15081. /**
  15082. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15083. */
  15084. getWorldMatrix(): Matrix;
  15085. /**
  15086. * Sets the local matrix to rest pose matrix
  15087. */
  15088. returnToRest(): void;
  15089. /**
  15090. * Gets the inverse of the absolute transform matrix.
  15091. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15092. * @returns a matrix
  15093. */
  15094. getInvertedAbsoluteTransform(): Matrix;
  15095. /**
  15096. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15097. * @returns a matrix
  15098. */
  15099. getAbsoluteTransform(): Matrix;
  15100. /**
  15101. * Links with the given transform node.
  15102. * The local matrix of this bone is copied from the transform node every frame.
  15103. * @param transformNode defines the transform node to link to
  15104. */
  15105. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15106. /**
  15107. * Gets the node used to drive the bone's transformation
  15108. * @returns a transform node or null
  15109. */
  15110. getTransformNode(): Nullable<TransformNode>;
  15111. /** Gets or sets current position (in local space) */
  15112. get position(): Vector3;
  15113. set position(newPosition: Vector3);
  15114. /** Gets or sets current rotation (in local space) */
  15115. get rotation(): Vector3;
  15116. set rotation(newRotation: Vector3);
  15117. /** Gets or sets current rotation quaternion (in local space) */
  15118. get rotationQuaternion(): Quaternion;
  15119. set rotationQuaternion(newRotation: Quaternion);
  15120. /** Gets or sets current scaling (in local space) */
  15121. get scaling(): Vector3;
  15122. set scaling(newScaling: Vector3);
  15123. /**
  15124. * Gets the animation properties override
  15125. */
  15126. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15127. private _decompose;
  15128. private _compose;
  15129. /**
  15130. * Update the base and local matrices
  15131. * @param matrix defines the new base or local matrix
  15132. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15133. * @param updateLocalMatrix defines if the local matrix should be updated
  15134. */
  15135. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15136. /** @hidden */
  15137. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15138. /**
  15139. * Flag the bone as dirty (Forcing it to update everything)
  15140. */
  15141. markAsDirty(): void;
  15142. /** @hidden */
  15143. _markAsDirtyAndCompose(): void;
  15144. private _markAsDirtyAndDecompose;
  15145. /**
  15146. * Translate the bone in local or world space
  15147. * @param vec The amount to translate the bone
  15148. * @param space The space that the translation is in
  15149. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15150. */
  15151. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15152. /**
  15153. * Set the postion of the bone in local or world space
  15154. * @param position The position to set the bone
  15155. * @param space The space that the position is in
  15156. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15157. */
  15158. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15159. /**
  15160. * Set the absolute position of the bone (world space)
  15161. * @param position The position to set the bone
  15162. * @param mesh The mesh that this bone is attached to
  15163. */
  15164. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15165. /**
  15166. * Scale the bone on the x, y and z axes (in local space)
  15167. * @param x The amount to scale the bone on the x axis
  15168. * @param y The amount to scale the bone on the y axis
  15169. * @param z The amount to scale the bone on the z axis
  15170. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15171. */
  15172. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15173. /**
  15174. * Set the bone scaling in local space
  15175. * @param scale defines the scaling vector
  15176. */
  15177. setScale(scale: Vector3): void;
  15178. /**
  15179. * Gets the current scaling in local space
  15180. * @returns the current scaling vector
  15181. */
  15182. getScale(): Vector3;
  15183. /**
  15184. * Gets the current scaling in local space and stores it in a target vector
  15185. * @param result defines the target vector
  15186. */
  15187. getScaleToRef(result: Vector3): void;
  15188. /**
  15189. * Set the yaw, pitch, and roll of the bone in local or world space
  15190. * @param yaw The rotation of the bone on the y axis
  15191. * @param pitch The rotation of the bone on the x axis
  15192. * @param roll The rotation of the bone on the z axis
  15193. * @param space The space that the axes of rotation are in
  15194. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15195. */
  15196. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15197. /**
  15198. * Add a rotation to the bone on an axis in local or world space
  15199. * @param axis The axis to rotate the bone on
  15200. * @param amount The amount to rotate the bone
  15201. * @param space The space that the axis is in
  15202. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15203. */
  15204. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15205. /**
  15206. * Set the rotation of the bone to a particular axis angle in local or world space
  15207. * @param axis The axis to rotate the bone on
  15208. * @param angle The angle that the bone should be rotated to
  15209. * @param space The space that the axis is in
  15210. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15211. */
  15212. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15213. /**
  15214. * Set the euler rotation of the bone in local of world space
  15215. * @param rotation The euler rotation that the bone should be set to
  15216. * @param space The space that the rotation is in
  15217. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15218. */
  15219. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15220. /**
  15221. * Set the quaternion rotation of the bone in local of world space
  15222. * @param quat The quaternion rotation that the bone should be set to
  15223. * @param space The space that the rotation is in
  15224. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15225. */
  15226. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15227. /**
  15228. * Set the rotation matrix of the bone in local of world space
  15229. * @param rotMat The rotation matrix that the bone should be set to
  15230. * @param space The space that the rotation is in
  15231. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15232. */
  15233. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15234. private _rotateWithMatrix;
  15235. private _getNegativeRotationToRef;
  15236. /**
  15237. * Get the position of the bone in local or world space
  15238. * @param space The space that the returned position is in
  15239. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15240. * @returns The position of the bone
  15241. */
  15242. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15243. /**
  15244. * Copy the position of the bone to a vector3 in local or world space
  15245. * @param space The space that the returned position is in
  15246. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15247. * @param result The vector3 to copy the position to
  15248. */
  15249. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15250. /**
  15251. * Get the absolute position of the bone (world space)
  15252. * @param mesh The mesh that this bone is attached to
  15253. * @returns The absolute position of the bone
  15254. */
  15255. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15256. /**
  15257. * Copy the absolute position of the bone (world space) to the result param
  15258. * @param mesh The mesh that this bone is attached to
  15259. * @param result The vector3 to copy the absolute position to
  15260. */
  15261. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15262. /**
  15263. * Compute the absolute transforms of this bone and its children
  15264. */
  15265. computeAbsoluteTransforms(): void;
  15266. /**
  15267. * Get the world direction from an axis that is in the local space of the bone
  15268. * @param localAxis The local direction that is used to compute the world direction
  15269. * @param mesh The mesh that this bone is attached to
  15270. * @returns The world direction
  15271. */
  15272. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15273. /**
  15274. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15275. * @param localAxis The local direction that is used to compute the world direction
  15276. * @param mesh The mesh that this bone is attached to
  15277. * @param result The vector3 that the world direction will be copied to
  15278. */
  15279. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15280. /**
  15281. * Get the euler rotation of the bone in local or world space
  15282. * @param space The space that the rotation should be in
  15283. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15284. * @returns The euler rotation
  15285. */
  15286. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15287. /**
  15288. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15289. * @param space The space that the rotation should be in
  15290. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15291. * @param result The vector3 that the rotation should be copied to
  15292. */
  15293. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15294. /**
  15295. * Get the quaternion rotation of the bone in either local or world space
  15296. * @param space The space that the rotation should be in
  15297. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15298. * @returns The quaternion rotation
  15299. */
  15300. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15301. /**
  15302. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15303. * @param space The space that the rotation should be in
  15304. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15305. * @param result The quaternion that the rotation should be copied to
  15306. */
  15307. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15308. /**
  15309. * Get the rotation matrix of the bone in local or world space
  15310. * @param space The space that the rotation should be in
  15311. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15312. * @returns The rotation matrix
  15313. */
  15314. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15315. /**
  15316. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15317. * @param space The space that the rotation should be in
  15318. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15319. * @param result The quaternion that the rotation should be copied to
  15320. */
  15321. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15322. /**
  15323. * Get the world position of a point that is in the local space of the bone
  15324. * @param position The local position
  15325. * @param mesh The mesh that this bone is attached to
  15326. * @returns The world position
  15327. */
  15328. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15329. /**
  15330. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15331. * @param position The local position
  15332. * @param mesh The mesh that this bone is attached to
  15333. * @param result The vector3 that the world position should be copied to
  15334. */
  15335. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15336. /**
  15337. * Get the local position of a point that is in world space
  15338. * @param position The world position
  15339. * @param mesh The mesh that this bone is attached to
  15340. * @returns The local position
  15341. */
  15342. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15343. /**
  15344. * Get the local position of a point that is in world space and copy it to the result param
  15345. * @param position The world position
  15346. * @param mesh The mesh that this bone is attached to
  15347. * @param result The vector3 that the local position should be copied to
  15348. */
  15349. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15350. }
  15351. }
  15352. declare module BABYLON {
  15353. /**
  15354. * Defines a runtime animation
  15355. */
  15356. export class RuntimeAnimation {
  15357. private _events;
  15358. /**
  15359. * The current frame of the runtime animation
  15360. */
  15361. private _currentFrame;
  15362. /**
  15363. * The animation used by the runtime animation
  15364. */
  15365. private _animation;
  15366. /**
  15367. * The target of the runtime animation
  15368. */
  15369. private _target;
  15370. /**
  15371. * The initiating animatable
  15372. */
  15373. private _host;
  15374. /**
  15375. * The original value of the runtime animation
  15376. */
  15377. private _originalValue;
  15378. /**
  15379. * The original blend value of the runtime animation
  15380. */
  15381. private _originalBlendValue;
  15382. /**
  15383. * The offsets cache of the runtime animation
  15384. */
  15385. private _offsetsCache;
  15386. /**
  15387. * The high limits cache of the runtime animation
  15388. */
  15389. private _highLimitsCache;
  15390. /**
  15391. * Specifies if the runtime animation has been stopped
  15392. */
  15393. private _stopped;
  15394. /**
  15395. * The blending factor of the runtime animation
  15396. */
  15397. private _blendingFactor;
  15398. /**
  15399. * The BabylonJS scene
  15400. */
  15401. private _scene;
  15402. /**
  15403. * The current value of the runtime animation
  15404. */
  15405. private _currentValue;
  15406. /** @hidden */
  15407. _animationState: _IAnimationState;
  15408. /**
  15409. * The active target of the runtime animation
  15410. */
  15411. private _activeTargets;
  15412. private _currentActiveTarget;
  15413. private _directTarget;
  15414. /**
  15415. * The target path of the runtime animation
  15416. */
  15417. private _targetPath;
  15418. /**
  15419. * The weight of the runtime animation
  15420. */
  15421. private _weight;
  15422. /**
  15423. * The ratio offset of the runtime animation
  15424. */
  15425. private _ratioOffset;
  15426. /**
  15427. * The previous delay of the runtime animation
  15428. */
  15429. private _previousDelay;
  15430. /**
  15431. * The previous ratio of the runtime animation
  15432. */
  15433. private _previousRatio;
  15434. private _enableBlending;
  15435. private _keys;
  15436. private _minFrame;
  15437. private _maxFrame;
  15438. private _minValue;
  15439. private _maxValue;
  15440. private _targetIsArray;
  15441. /**
  15442. * Gets the current frame of the runtime animation
  15443. */
  15444. get currentFrame(): number;
  15445. /**
  15446. * Gets the weight of the runtime animation
  15447. */
  15448. get weight(): number;
  15449. /**
  15450. * Gets the current value of the runtime animation
  15451. */
  15452. get currentValue(): any;
  15453. /**
  15454. * Gets the target path of the runtime animation
  15455. */
  15456. get targetPath(): string;
  15457. /**
  15458. * Gets the actual target of the runtime animation
  15459. */
  15460. get target(): any;
  15461. /**
  15462. * Gets the additive state of the runtime animation
  15463. */
  15464. get isAdditive(): boolean;
  15465. /** @hidden */
  15466. _onLoop: () => void;
  15467. /**
  15468. * Create a new RuntimeAnimation object
  15469. * @param target defines the target of the animation
  15470. * @param animation defines the source animation object
  15471. * @param scene defines the hosting scene
  15472. * @param host defines the initiating Animatable
  15473. */
  15474. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15475. private _preparePath;
  15476. /**
  15477. * Gets the animation from the runtime animation
  15478. */
  15479. get animation(): Animation;
  15480. /**
  15481. * Resets the runtime animation to the beginning
  15482. * @param restoreOriginal defines whether to restore the target property to the original value
  15483. */
  15484. reset(restoreOriginal?: boolean): void;
  15485. /**
  15486. * Specifies if the runtime animation is stopped
  15487. * @returns Boolean specifying if the runtime animation is stopped
  15488. */
  15489. isStopped(): boolean;
  15490. /**
  15491. * Disposes of the runtime animation
  15492. */
  15493. dispose(): void;
  15494. /**
  15495. * Apply the interpolated value to the target
  15496. * @param currentValue defines the value computed by the animation
  15497. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15498. */
  15499. setValue(currentValue: any, weight: number): void;
  15500. private _getOriginalValues;
  15501. private _setValue;
  15502. /**
  15503. * Gets the loop pmode of the runtime animation
  15504. * @returns Loop Mode
  15505. */
  15506. private _getCorrectLoopMode;
  15507. /**
  15508. * Move the current animation to a given frame
  15509. * @param frame defines the frame to move to
  15510. */
  15511. goToFrame(frame: number): void;
  15512. /**
  15513. * @hidden Internal use only
  15514. */
  15515. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15516. /**
  15517. * Execute the current animation
  15518. * @param delay defines the delay to add to the current frame
  15519. * @param from defines the lower bound of the animation range
  15520. * @param to defines the upper bound of the animation range
  15521. * @param loop defines if the current animation must loop
  15522. * @param speedRatio defines the current speed ratio
  15523. * @param weight defines the weight of the animation (default is -1 so no weight)
  15524. * @param onLoop optional callback called when animation loops
  15525. * @returns a boolean indicating if the animation is running
  15526. */
  15527. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15528. }
  15529. }
  15530. declare module BABYLON {
  15531. /**
  15532. * Class used to store an actual running animation
  15533. */
  15534. export class Animatable {
  15535. /** defines the target object */
  15536. target: any;
  15537. /** defines the starting frame number (default is 0) */
  15538. fromFrame: number;
  15539. /** defines the ending frame number (default is 100) */
  15540. toFrame: number;
  15541. /** defines if the animation must loop (default is false) */
  15542. loopAnimation: boolean;
  15543. /** defines a callback to call when animation ends if it is not looping */
  15544. onAnimationEnd?: (() => void) | null | undefined;
  15545. /** defines a callback to call when animation loops */
  15546. onAnimationLoop?: (() => void) | null | undefined;
  15547. /** defines whether the animation should be evaluated additively */
  15548. isAdditive: boolean;
  15549. private _localDelayOffset;
  15550. private _pausedDelay;
  15551. private _runtimeAnimations;
  15552. private _paused;
  15553. private _scene;
  15554. private _speedRatio;
  15555. private _weight;
  15556. private _syncRoot;
  15557. /**
  15558. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15559. * This will only apply for non looping animation (default is true)
  15560. */
  15561. disposeOnEnd: boolean;
  15562. /**
  15563. * Gets a boolean indicating if the animation has started
  15564. */
  15565. animationStarted: boolean;
  15566. /**
  15567. * Observer raised when the animation ends
  15568. */
  15569. onAnimationEndObservable: Observable<Animatable>;
  15570. /**
  15571. * Observer raised when the animation loops
  15572. */
  15573. onAnimationLoopObservable: Observable<Animatable>;
  15574. /**
  15575. * Gets the root Animatable used to synchronize and normalize animations
  15576. */
  15577. get syncRoot(): Nullable<Animatable>;
  15578. /**
  15579. * Gets the current frame of the first RuntimeAnimation
  15580. * Used to synchronize Animatables
  15581. */
  15582. get masterFrame(): number;
  15583. /**
  15584. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15585. */
  15586. get weight(): number;
  15587. set weight(value: number);
  15588. /**
  15589. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15590. */
  15591. get speedRatio(): number;
  15592. set speedRatio(value: number);
  15593. /**
  15594. * Creates a new Animatable
  15595. * @param scene defines the hosting scene
  15596. * @param target defines the target object
  15597. * @param fromFrame defines the starting frame number (default is 0)
  15598. * @param toFrame defines the ending frame number (default is 100)
  15599. * @param loopAnimation defines if the animation must loop (default is false)
  15600. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15601. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15602. * @param animations defines a group of animation to add to the new Animatable
  15603. * @param onAnimationLoop defines a callback to call when animation loops
  15604. * @param isAdditive defines whether the animation should be evaluated additively
  15605. */
  15606. constructor(scene: Scene,
  15607. /** defines the target object */
  15608. target: any,
  15609. /** defines the starting frame number (default is 0) */
  15610. fromFrame?: number,
  15611. /** defines the ending frame number (default is 100) */
  15612. toFrame?: number,
  15613. /** defines if the animation must loop (default is false) */
  15614. loopAnimation?: boolean, speedRatio?: number,
  15615. /** defines a callback to call when animation ends if it is not looping */
  15616. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15617. /** defines a callback to call when animation loops */
  15618. onAnimationLoop?: (() => void) | null | undefined,
  15619. /** defines whether the animation should be evaluated additively */
  15620. isAdditive?: boolean);
  15621. /**
  15622. * Synchronize and normalize current Animatable with a source Animatable
  15623. * This is useful when using animation weights and when animations are not of the same length
  15624. * @param root defines the root Animatable to synchronize with
  15625. * @returns the current Animatable
  15626. */
  15627. syncWith(root: Animatable): Animatable;
  15628. /**
  15629. * Gets the list of runtime animations
  15630. * @returns an array of RuntimeAnimation
  15631. */
  15632. getAnimations(): RuntimeAnimation[];
  15633. /**
  15634. * Adds more animations to the current animatable
  15635. * @param target defines the target of the animations
  15636. * @param animations defines the new animations to add
  15637. */
  15638. appendAnimations(target: any, animations: Animation[]): void;
  15639. /**
  15640. * Gets the source animation for a specific property
  15641. * @param property defines the propertyu to look for
  15642. * @returns null or the source animation for the given property
  15643. */
  15644. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15645. /**
  15646. * Gets the runtime animation for a specific property
  15647. * @param property defines the propertyu to look for
  15648. * @returns null or the runtime animation for the given property
  15649. */
  15650. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15651. /**
  15652. * Resets the animatable to its original state
  15653. */
  15654. reset(): void;
  15655. /**
  15656. * Allows the animatable to blend with current running animations
  15657. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15658. * @param blendingSpeed defines the blending speed to use
  15659. */
  15660. enableBlending(blendingSpeed: number): void;
  15661. /**
  15662. * Disable animation blending
  15663. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15664. */
  15665. disableBlending(): void;
  15666. /**
  15667. * Jump directly to a given frame
  15668. * @param frame defines the frame to jump to
  15669. */
  15670. goToFrame(frame: number): void;
  15671. /**
  15672. * Pause the animation
  15673. */
  15674. pause(): void;
  15675. /**
  15676. * Restart the animation
  15677. */
  15678. restart(): void;
  15679. private _raiseOnAnimationEnd;
  15680. /**
  15681. * Stop and delete the current animation
  15682. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15683. * @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)
  15684. */
  15685. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15686. /**
  15687. * Wait asynchronously for the animation to end
  15688. * @returns a promise which will be fullfilled when the animation ends
  15689. */
  15690. waitAsync(): Promise<Animatable>;
  15691. /** @hidden */
  15692. _animate(delay: number): boolean;
  15693. }
  15694. interface Scene {
  15695. /** @hidden */
  15696. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15697. /** @hidden */
  15698. _processLateAnimationBindingsForMatrices(holder: {
  15699. totalWeight: number;
  15700. totalAdditiveWeight: number;
  15701. animations: RuntimeAnimation[];
  15702. additiveAnimations: RuntimeAnimation[];
  15703. originalValue: Matrix;
  15704. }): any;
  15705. /** @hidden */
  15706. _processLateAnimationBindingsForQuaternions(holder: {
  15707. totalWeight: number;
  15708. totalAdditiveWeight: number;
  15709. animations: RuntimeAnimation[];
  15710. additiveAnimations: RuntimeAnimation[];
  15711. originalValue: Quaternion;
  15712. }, refQuaternion: Quaternion): Quaternion;
  15713. /** @hidden */
  15714. _processLateAnimationBindings(): void;
  15715. /**
  15716. * Will start the animation sequence of a given target
  15717. * @param target defines the target
  15718. * @param from defines from which frame should animation start
  15719. * @param to defines until which frame should animation run.
  15720. * @param weight defines the weight to apply to the animation (1.0 by default)
  15721. * @param loop defines if the animation loops
  15722. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15723. * @param onAnimationEnd defines the function to be executed when the animation ends
  15724. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15725. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15726. * @param onAnimationLoop defines the callback to call when an animation loops
  15727. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15728. * @returns the animatable object created for this animation
  15729. */
  15730. 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;
  15731. /**
  15732. * Will start the animation sequence of a given target
  15733. * @param target defines the target
  15734. * @param from defines from which frame should animation start
  15735. * @param to defines until which frame should animation run.
  15736. * @param loop defines if the animation loops
  15737. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15738. * @param onAnimationEnd defines the function to be executed when the animation ends
  15739. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15740. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15741. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15742. * @param onAnimationLoop defines the callback to call when an animation loops
  15743. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15744. * @returns the animatable object created for this animation
  15745. */
  15746. 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;
  15747. /**
  15748. * Will start the animation sequence of a given target and its hierarchy
  15749. * @param target defines the target
  15750. * @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.
  15751. * @param from defines from which frame should animation start
  15752. * @param to defines until which frame should animation run.
  15753. * @param loop defines if the animation loops
  15754. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15755. * @param onAnimationEnd defines the function to be executed when the animation ends
  15756. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15757. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15758. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15759. * @param onAnimationLoop defines the callback to call when an animation loops
  15760. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15761. * @returns the list of created animatables
  15762. */
  15763. 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[];
  15764. /**
  15765. * Begin a new animation on a given node
  15766. * @param target defines the target where the animation will take place
  15767. * @param animations defines the list of animations to start
  15768. * @param from defines the initial value
  15769. * @param to defines the final value
  15770. * @param loop defines if you want animation to loop (off by default)
  15771. * @param speedRatio defines the speed ratio to apply to all animations
  15772. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15773. * @param onAnimationLoop defines the callback to call when an animation loops
  15774. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15775. * @returns the list of created animatables
  15776. */
  15777. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15778. /**
  15779. * Begin a new animation on a given node and its hierarchy
  15780. * @param target defines the root node where the animation will take place
  15781. * @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.
  15782. * @param animations defines the list of animations to start
  15783. * @param from defines the initial value
  15784. * @param to defines the final value
  15785. * @param loop defines if you want animation to loop (off by default)
  15786. * @param speedRatio defines the speed ratio to apply to all animations
  15787. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15788. * @param onAnimationLoop defines the callback to call when an animation loops
  15789. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15790. * @returns the list of animatables created for all nodes
  15791. */
  15792. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15793. /**
  15794. * Gets the animatable associated with a specific target
  15795. * @param target defines the target of the animatable
  15796. * @returns the required animatable if found
  15797. */
  15798. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15799. /**
  15800. * Gets all animatables associated with a given target
  15801. * @param target defines the target to look animatables for
  15802. * @returns an array of Animatables
  15803. */
  15804. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15805. /**
  15806. * Stops and removes all animations that have been applied to the scene
  15807. */
  15808. stopAllAnimations(): void;
  15809. /**
  15810. * Gets the current delta time used by animation engine
  15811. */
  15812. deltaTime: number;
  15813. }
  15814. interface Bone {
  15815. /**
  15816. * Copy an animation range from another bone
  15817. * @param source defines the source bone
  15818. * @param rangeName defines the range name to copy
  15819. * @param frameOffset defines the frame offset
  15820. * @param rescaleAsRequired defines if rescaling must be applied if required
  15821. * @param skelDimensionsRatio defines the scaling ratio
  15822. * @returns true if operation was successful
  15823. */
  15824. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15825. }
  15826. }
  15827. declare module BABYLON {
  15828. /**
  15829. * Class used to handle skinning animations
  15830. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15831. */
  15832. export class Skeleton implements IAnimatable {
  15833. /** defines the skeleton name */
  15834. name: string;
  15835. /** defines the skeleton Id */
  15836. id: string;
  15837. /**
  15838. * Defines the list of child bones
  15839. */
  15840. bones: Bone[];
  15841. /**
  15842. * Defines an estimate of the dimension of the skeleton at rest
  15843. */
  15844. dimensionsAtRest: Vector3;
  15845. /**
  15846. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15847. */
  15848. needInitialSkinMatrix: boolean;
  15849. /**
  15850. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15851. */
  15852. overrideMesh: Nullable<AbstractMesh>;
  15853. /**
  15854. * Gets the list of animations attached to this skeleton
  15855. */
  15856. animations: Array<Animation>;
  15857. private _scene;
  15858. private _isDirty;
  15859. private _transformMatrices;
  15860. private _transformMatrixTexture;
  15861. private _meshesWithPoseMatrix;
  15862. private _animatables;
  15863. private _identity;
  15864. private _synchronizedWithMesh;
  15865. private _ranges;
  15866. private _lastAbsoluteTransformsUpdateId;
  15867. private _canUseTextureForBones;
  15868. private _uniqueId;
  15869. /** @hidden */
  15870. _numBonesWithLinkedTransformNode: number;
  15871. /** @hidden */
  15872. _hasWaitingData: Nullable<boolean>;
  15873. /**
  15874. * Specifies if the skeleton should be serialized
  15875. */
  15876. doNotSerialize: boolean;
  15877. private _useTextureToStoreBoneMatrices;
  15878. /**
  15879. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15880. * Please note that this option is not available if the hardware does not support it
  15881. */
  15882. get useTextureToStoreBoneMatrices(): boolean;
  15883. set useTextureToStoreBoneMatrices(value: boolean);
  15884. private _animationPropertiesOverride;
  15885. /**
  15886. * Gets or sets the animation properties override
  15887. */
  15888. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15889. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15890. /**
  15891. * List of inspectable custom properties (used by the Inspector)
  15892. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15893. */
  15894. inspectableCustomProperties: IInspectable[];
  15895. /**
  15896. * An observable triggered before computing the skeleton's matrices
  15897. */
  15898. onBeforeComputeObservable: Observable<Skeleton>;
  15899. /**
  15900. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15901. */
  15902. get isUsingTextureForMatrices(): boolean;
  15903. /**
  15904. * Gets the unique ID of this skeleton
  15905. */
  15906. get uniqueId(): number;
  15907. /**
  15908. * Creates a new skeleton
  15909. * @param name defines the skeleton name
  15910. * @param id defines the skeleton Id
  15911. * @param scene defines the hosting scene
  15912. */
  15913. constructor(
  15914. /** defines the skeleton name */
  15915. name: string,
  15916. /** defines the skeleton Id */
  15917. id: string, scene: Scene);
  15918. /**
  15919. * Gets the current object class name.
  15920. * @return the class name
  15921. */
  15922. getClassName(): string;
  15923. /**
  15924. * Returns an array containing the root bones
  15925. * @returns an array containing the root bones
  15926. */
  15927. getChildren(): Array<Bone>;
  15928. /**
  15929. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15930. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15931. * @returns a Float32Array containing matrices data
  15932. */
  15933. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15934. /**
  15935. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15936. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15937. * @returns a raw texture containing the data
  15938. */
  15939. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15940. /**
  15941. * Gets the current hosting scene
  15942. * @returns a scene object
  15943. */
  15944. getScene(): Scene;
  15945. /**
  15946. * Gets a string representing the current skeleton data
  15947. * @param fullDetails defines a boolean indicating if we want a verbose version
  15948. * @returns a string representing the current skeleton data
  15949. */
  15950. toString(fullDetails?: boolean): string;
  15951. /**
  15952. * Get bone's index searching by name
  15953. * @param name defines bone's name to search for
  15954. * @return the indice of the bone. Returns -1 if not found
  15955. */
  15956. getBoneIndexByName(name: string): number;
  15957. /**
  15958. * Creater a new animation range
  15959. * @param name defines the name of the range
  15960. * @param from defines the start key
  15961. * @param to defines the end key
  15962. */
  15963. createAnimationRange(name: string, from: number, to: number): void;
  15964. /**
  15965. * Delete a specific animation range
  15966. * @param name defines the name of the range
  15967. * @param deleteFrames defines if frames must be removed as well
  15968. */
  15969. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15970. /**
  15971. * Gets a specific animation range
  15972. * @param name defines the name of the range to look for
  15973. * @returns the requested animation range or null if not found
  15974. */
  15975. getAnimationRange(name: string): Nullable<AnimationRange>;
  15976. /**
  15977. * Gets the list of all animation ranges defined on this skeleton
  15978. * @returns an array
  15979. */
  15980. getAnimationRanges(): Nullable<AnimationRange>[];
  15981. /**
  15982. * Copy animation range from a source skeleton.
  15983. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15984. * @param source defines the source skeleton
  15985. * @param name defines the name of the range to copy
  15986. * @param rescaleAsRequired defines if rescaling must be applied if required
  15987. * @returns true if operation was successful
  15988. */
  15989. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15990. /**
  15991. * Forces the skeleton to go to rest pose
  15992. */
  15993. returnToRest(): void;
  15994. private _getHighestAnimationFrame;
  15995. /**
  15996. * Begin a specific animation range
  15997. * @param name defines the name of the range to start
  15998. * @param loop defines if looping must be turned on (false by default)
  15999. * @param speedRatio defines the speed ratio to apply (1 by default)
  16000. * @param onAnimationEnd defines a callback which will be called when animation will end
  16001. * @returns a new animatable
  16002. */
  16003. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16004. /**
  16005. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16006. * @param skeleton defines the Skeleton containing the animation range to convert
  16007. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16008. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16009. * @returns the original skeleton
  16010. */
  16011. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16012. /** @hidden */
  16013. _markAsDirty(): void;
  16014. /** @hidden */
  16015. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16016. /** @hidden */
  16017. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16018. private _computeTransformMatrices;
  16019. /**
  16020. * Build all resources required to render a skeleton
  16021. */
  16022. prepare(): void;
  16023. /**
  16024. * Gets the list of animatables currently running for this skeleton
  16025. * @returns an array of animatables
  16026. */
  16027. getAnimatables(): IAnimatable[];
  16028. /**
  16029. * Clone the current skeleton
  16030. * @param name defines the name of the new skeleton
  16031. * @param id defines the id of the new skeleton
  16032. * @returns the new skeleton
  16033. */
  16034. clone(name: string, id?: string): Skeleton;
  16035. /**
  16036. * Enable animation blending for this skeleton
  16037. * @param blendingSpeed defines the blending speed to apply
  16038. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  16039. */
  16040. enableBlending(blendingSpeed?: number): void;
  16041. /**
  16042. * Releases all resources associated with the current skeleton
  16043. */
  16044. dispose(): void;
  16045. /**
  16046. * Serialize the skeleton in a JSON object
  16047. * @returns a JSON object
  16048. */
  16049. serialize(): any;
  16050. /**
  16051. * Creates a new skeleton from serialized data
  16052. * @param parsedSkeleton defines the serialized data
  16053. * @param scene defines the hosting scene
  16054. * @returns a new skeleton
  16055. */
  16056. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16057. /**
  16058. * Compute all node absolute transforms
  16059. * @param forceUpdate defines if computation must be done even if cache is up to date
  16060. */
  16061. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16062. /**
  16063. * Gets the root pose matrix
  16064. * @returns a matrix
  16065. */
  16066. getPoseMatrix(): Nullable<Matrix>;
  16067. /**
  16068. * Sorts bones per internal index
  16069. */
  16070. sortBones(): void;
  16071. private _sortBones;
  16072. }
  16073. }
  16074. declare module BABYLON {
  16075. /**
  16076. * Creates an instance based on a source mesh.
  16077. */
  16078. export class InstancedMesh extends AbstractMesh {
  16079. private _sourceMesh;
  16080. private _currentLOD;
  16081. /** @hidden */
  16082. _indexInSourceMeshInstanceArray: number;
  16083. constructor(name: string, source: Mesh);
  16084. /**
  16085. * Returns the string "InstancedMesh".
  16086. */
  16087. getClassName(): string;
  16088. /** Gets the list of lights affecting that mesh */
  16089. get lightSources(): Light[];
  16090. _resyncLightSources(): void;
  16091. _resyncLightSource(light: Light): void;
  16092. _removeLightSource(light: Light, dispose: boolean): void;
  16093. /**
  16094. * If the source mesh receives shadows
  16095. */
  16096. get receiveShadows(): boolean;
  16097. /**
  16098. * The material of the source mesh
  16099. */
  16100. get material(): Nullable<Material>;
  16101. /**
  16102. * Visibility of the source mesh
  16103. */
  16104. get visibility(): number;
  16105. /**
  16106. * Skeleton of the source mesh
  16107. */
  16108. get skeleton(): Nullable<Skeleton>;
  16109. /**
  16110. * Rendering ground id of the source mesh
  16111. */
  16112. get renderingGroupId(): number;
  16113. set renderingGroupId(value: number);
  16114. /**
  16115. * Returns the total number of vertices (integer).
  16116. */
  16117. getTotalVertices(): number;
  16118. /**
  16119. * Returns a positive integer : the total number of indices in this mesh geometry.
  16120. * @returns the numner of indices or zero if the mesh has no geometry.
  16121. */
  16122. getTotalIndices(): number;
  16123. /**
  16124. * The source mesh of the instance
  16125. */
  16126. get sourceMesh(): Mesh;
  16127. /**
  16128. * Is this node ready to be used/rendered
  16129. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16130. * @return {boolean} is it ready
  16131. */
  16132. isReady(completeCheck?: boolean): boolean;
  16133. /**
  16134. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16135. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16136. * @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.
  16137. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16138. */
  16139. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16140. /**
  16141. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16142. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16143. * The `data` are either a numeric array either a Float32Array.
  16144. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16145. * 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).
  16146. * Note that a new underlying VertexBuffer object is created each call.
  16147. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16148. *
  16149. * Possible `kind` values :
  16150. * - VertexBuffer.PositionKind
  16151. * - VertexBuffer.UVKind
  16152. * - VertexBuffer.UV2Kind
  16153. * - VertexBuffer.UV3Kind
  16154. * - VertexBuffer.UV4Kind
  16155. * - VertexBuffer.UV5Kind
  16156. * - VertexBuffer.UV6Kind
  16157. * - VertexBuffer.ColorKind
  16158. * - VertexBuffer.MatricesIndicesKind
  16159. * - VertexBuffer.MatricesIndicesExtraKind
  16160. * - VertexBuffer.MatricesWeightsKind
  16161. * - VertexBuffer.MatricesWeightsExtraKind
  16162. *
  16163. * Returns the Mesh.
  16164. */
  16165. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16166. /**
  16167. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16168. * If the mesh has no geometry, it is simply returned as it is.
  16169. * The `data` are either a numeric array either a Float32Array.
  16170. * No new underlying VertexBuffer object is created.
  16171. * 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.
  16172. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16173. *
  16174. * Possible `kind` values :
  16175. * - VertexBuffer.PositionKind
  16176. * - VertexBuffer.UVKind
  16177. * - VertexBuffer.UV2Kind
  16178. * - VertexBuffer.UV3Kind
  16179. * - VertexBuffer.UV4Kind
  16180. * - VertexBuffer.UV5Kind
  16181. * - VertexBuffer.UV6Kind
  16182. * - VertexBuffer.ColorKind
  16183. * - VertexBuffer.MatricesIndicesKind
  16184. * - VertexBuffer.MatricesIndicesExtraKind
  16185. * - VertexBuffer.MatricesWeightsKind
  16186. * - VertexBuffer.MatricesWeightsExtraKind
  16187. *
  16188. * Returns the Mesh.
  16189. */
  16190. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16191. /**
  16192. * Sets the mesh indices.
  16193. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16194. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16195. * This method creates a new index buffer each call.
  16196. * Returns the Mesh.
  16197. */
  16198. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16199. /**
  16200. * Boolean : True if the mesh owns the requested kind of data.
  16201. */
  16202. isVerticesDataPresent(kind: string): boolean;
  16203. /**
  16204. * Returns an array of indices (IndicesArray).
  16205. */
  16206. getIndices(): Nullable<IndicesArray>;
  16207. get _positions(): Nullable<Vector3[]>;
  16208. /**
  16209. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16210. * This means the mesh underlying bounding box and sphere are recomputed.
  16211. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16212. * @returns the current mesh
  16213. */
  16214. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16215. /** @hidden */
  16216. _preActivate(): InstancedMesh;
  16217. /** @hidden */
  16218. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16219. /** @hidden */
  16220. _postActivate(): void;
  16221. getWorldMatrix(): Matrix;
  16222. get isAnInstance(): boolean;
  16223. /**
  16224. * Returns the current associated LOD AbstractMesh.
  16225. */
  16226. getLOD(camera: Camera): AbstractMesh;
  16227. /** @hidden */
  16228. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16229. /** @hidden */
  16230. _syncSubMeshes(): InstancedMesh;
  16231. /** @hidden */
  16232. _generatePointsArray(): boolean;
  16233. /**
  16234. * Creates a new InstancedMesh from the current mesh.
  16235. * - name (string) : the cloned mesh name
  16236. * - newParent (optional Node) : the optional Node to parent the clone to.
  16237. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16238. *
  16239. * Returns the clone.
  16240. */
  16241. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16242. /**
  16243. * Disposes the InstancedMesh.
  16244. * Returns nothing.
  16245. */
  16246. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16247. }
  16248. interface Mesh {
  16249. /**
  16250. * Register a custom buffer that will be instanced
  16251. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16252. * @param kind defines the buffer kind
  16253. * @param stride defines the stride in floats
  16254. */
  16255. registerInstancedBuffer(kind: string, stride: number): void;
  16256. /** @hidden */
  16257. _userInstancedBuffersStorage: {
  16258. data: {
  16259. [key: string]: Float32Array;
  16260. };
  16261. sizes: {
  16262. [key: string]: number;
  16263. };
  16264. vertexBuffers: {
  16265. [key: string]: Nullable<VertexBuffer>;
  16266. };
  16267. strides: {
  16268. [key: string]: number;
  16269. };
  16270. };
  16271. }
  16272. interface AbstractMesh {
  16273. /**
  16274. * Object used to store instanced buffers defined by user
  16275. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16276. */
  16277. instancedBuffers: {
  16278. [key: string]: any;
  16279. };
  16280. }
  16281. }
  16282. declare module BABYLON {
  16283. /**
  16284. * Defines the options associated with the creation of a shader material.
  16285. */
  16286. export interface IShaderMaterialOptions {
  16287. /**
  16288. * Does the material work in alpha blend mode
  16289. */
  16290. needAlphaBlending: boolean;
  16291. /**
  16292. * Does the material work in alpha test mode
  16293. */
  16294. needAlphaTesting: boolean;
  16295. /**
  16296. * The list of attribute names used in the shader
  16297. */
  16298. attributes: string[];
  16299. /**
  16300. * The list of unifrom names used in the shader
  16301. */
  16302. uniforms: string[];
  16303. /**
  16304. * The list of UBO names used in the shader
  16305. */
  16306. uniformBuffers: string[];
  16307. /**
  16308. * The list of sampler names used in the shader
  16309. */
  16310. samplers: string[];
  16311. /**
  16312. * The list of defines used in the shader
  16313. */
  16314. defines: string[];
  16315. }
  16316. /**
  16317. * 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.
  16318. *
  16319. * This returned material effects how the mesh will look based on the code in the shaders.
  16320. *
  16321. * @see http://doc.babylonjs.com/how_to/shader_material
  16322. */
  16323. export class ShaderMaterial extends Material {
  16324. private _shaderPath;
  16325. private _options;
  16326. private _textures;
  16327. private _textureArrays;
  16328. private _floats;
  16329. private _ints;
  16330. private _floatsArrays;
  16331. private _colors3;
  16332. private _colors3Arrays;
  16333. private _colors4;
  16334. private _colors4Arrays;
  16335. private _vectors2;
  16336. private _vectors3;
  16337. private _vectors4;
  16338. private _matrices;
  16339. private _matrixArrays;
  16340. private _matrices3x3;
  16341. private _matrices2x2;
  16342. private _vectors2Arrays;
  16343. private _vectors3Arrays;
  16344. private _vectors4Arrays;
  16345. private _cachedWorldViewMatrix;
  16346. private _cachedWorldViewProjectionMatrix;
  16347. private _renderId;
  16348. private _multiview;
  16349. private _cachedDefines;
  16350. /**
  16351. * Instantiate a new shader material.
  16352. * 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.
  16353. * This returned material effects how the mesh will look based on the code in the shaders.
  16354. * @see http://doc.babylonjs.com/how_to/shader_material
  16355. * @param name Define the name of the material in the scene
  16356. * @param scene Define the scene the material belongs to
  16357. * @param shaderPath Defines the route to the shader code in one of three ways:
  16358. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16359. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16360. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16361. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16362. * @param options Define the options used to create the shader
  16363. */
  16364. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16365. /**
  16366. * Gets the shader path used to define the shader code
  16367. * It can be modified to trigger a new compilation
  16368. */
  16369. get shaderPath(): any;
  16370. /**
  16371. * Sets the shader path used to define the shader code
  16372. * It can be modified to trigger a new compilation
  16373. */
  16374. set shaderPath(shaderPath: any);
  16375. /**
  16376. * Gets the options used to compile the shader.
  16377. * They can be modified to trigger a new compilation
  16378. */
  16379. get options(): IShaderMaterialOptions;
  16380. /**
  16381. * Gets the current class name of the material e.g. "ShaderMaterial"
  16382. * Mainly use in serialization.
  16383. * @returns the class name
  16384. */
  16385. getClassName(): string;
  16386. /**
  16387. * Specifies if the material will require alpha blending
  16388. * @returns a boolean specifying if alpha blending is needed
  16389. */
  16390. needAlphaBlending(): boolean;
  16391. /**
  16392. * Specifies if this material should be rendered in alpha test mode
  16393. * @returns a boolean specifying if an alpha test is needed.
  16394. */
  16395. needAlphaTesting(): boolean;
  16396. private _checkUniform;
  16397. /**
  16398. * Set a texture in the shader.
  16399. * @param name Define the name of the uniform samplers as defined in the shader
  16400. * @param texture Define the texture to bind to this sampler
  16401. * @return the material itself allowing "fluent" like uniform updates
  16402. */
  16403. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16404. /**
  16405. * Set a texture array in the shader.
  16406. * @param name Define the name of the uniform sampler array as defined in the shader
  16407. * @param textures Define the list of textures to bind to this sampler
  16408. * @return the material itself allowing "fluent" like uniform updates
  16409. */
  16410. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16411. /**
  16412. * Set a float in the shader.
  16413. * @param name Define the name of the uniform as defined in the shader
  16414. * @param value Define the value to give to the uniform
  16415. * @return the material itself allowing "fluent" like uniform updates
  16416. */
  16417. setFloat(name: string, value: number): ShaderMaterial;
  16418. /**
  16419. * Set a int in the shader.
  16420. * @param name Define the name of the uniform as defined in the shader
  16421. * @param value Define the value to give to the uniform
  16422. * @return the material itself allowing "fluent" like uniform updates
  16423. */
  16424. setInt(name: string, value: number): ShaderMaterial;
  16425. /**
  16426. * Set an array of floats in the shader.
  16427. * @param name Define the name of the uniform as defined in the shader
  16428. * @param value Define the value to give to the uniform
  16429. * @return the material itself allowing "fluent" like uniform updates
  16430. */
  16431. setFloats(name: string, value: number[]): ShaderMaterial;
  16432. /**
  16433. * Set a vec3 in the shader from a Color3.
  16434. * @param name Define the name of the uniform as defined in the shader
  16435. * @param value Define the value to give to the uniform
  16436. * @return the material itself allowing "fluent" like uniform updates
  16437. */
  16438. setColor3(name: string, value: Color3): ShaderMaterial;
  16439. /**
  16440. * Set a vec3 array in the shader from a Color3 array.
  16441. * @param name Define the name of the uniform as defined in the shader
  16442. * @param value Define the value to give to the uniform
  16443. * @return the material itself allowing "fluent" like uniform updates
  16444. */
  16445. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16446. /**
  16447. * Set a vec4 in the shader from a Color4.
  16448. * @param name Define the name of the uniform as defined in the shader
  16449. * @param value Define the value to give to the uniform
  16450. * @return the material itself allowing "fluent" like uniform updates
  16451. */
  16452. setColor4(name: string, value: Color4): ShaderMaterial;
  16453. /**
  16454. * Set a vec4 array in the shader from a Color4 array.
  16455. * @param name Define the name of the uniform as defined in the shader
  16456. * @param value Define the value to give to the uniform
  16457. * @return the material itself allowing "fluent" like uniform updates
  16458. */
  16459. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16460. /**
  16461. * Set a vec2 in the shader from a Vector2.
  16462. * @param name Define the name of the uniform as defined in the shader
  16463. * @param value Define the value to give to the uniform
  16464. * @return the material itself allowing "fluent" like uniform updates
  16465. */
  16466. setVector2(name: string, value: Vector2): ShaderMaterial;
  16467. /**
  16468. * Set a vec3 in the shader from a Vector3.
  16469. * @param name Define the name of the uniform as defined in the shader
  16470. * @param value Define the value to give to the uniform
  16471. * @return the material itself allowing "fluent" like uniform updates
  16472. */
  16473. setVector3(name: string, value: Vector3): ShaderMaterial;
  16474. /**
  16475. * Set a vec4 in the shader from a Vector4.
  16476. * @param name Define the name of the uniform as defined in the shader
  16477. * @param value Define the value to give to the uniform
  16478. * @return the material itself allowing "fluent" like uniform updates
  16479. */
  16480. setVector4(name: string, value: Vector4): ShaderMaterial;
  16481. /**
  16482. * Set a mat4 in the shader from a Matrix.
  16483. * @param name Define the name of the uniform as defined in the shader
  16484. * @param value Define the value to give to the uniform
  16485. * @return the material itself allowing "fluent" like uniform updates
  16486. */
  16487. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16488. /**
  16489. * Set a float32Array in the shader from a matrix array.
  16490. * @param name Define the name of the uniform as defined in the shader
  16491. * @param value Define the value to give to the uniform
  16492. * @return the material itself allowing "fluent" like uniform updates
  16493. */
  16494. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16495. /**
  16496. * Set a mat3 in the shader from a Float32Array.
  16497. * @param name Define the name of the uniform as defined in the shader
  16498. * @param value Define the value to give to the uniform
  16499. * @return the material itself allowing "fluent" like uniform updates
  16500. */
  16501. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16502. /**
  16503. * Set a mat2 in the shader from a Float32Array.
  16504. * @param name Define the name of the uniform as defined in the shader
  16505. * @param value Define the value to give to the uniform
  16506. * @return the material itself allowing "fluent" like uniform updates
  16507. */
  16508. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16509. /**
  16510. * Set a vec2 array in the shader from a number array.
  16511. * @param name Define the name of the uniform as defined in the shader
  16512. * @param value Define the value to give to the uniform
  16513. * @return the material itself allowing "fluent" like uniform updates
  16514. */
  16515. setArray2(name: string, value: number[]): ShaderMaterial;
  16516. /**
  16517. * Set a vec3 array in the shader from a number array.
  16518. * @param name Define the name of the uniform as defined in the shader
  16519. * @param value Define the value to give to the uniform
  16520. * @return the material itself allowing "fluent" like uniform updates
  16521. */
  16522. setArray3(name: string, value: number[]): ShaderMaterial;
  16523. /**
  16524. * Set a vec4 array in the shader from a number array.
  16525. * @param name Define the name of the uniform as defined in the shader
  16526. * @param value Define the value to give to the uniform
  16527. * @return the material itself allowing "fluent" like uniform updates
  16528. */
  16529. setArray4(name: string, value: number[]): ShaderMaterial;
  16530. private _checkCache;
  16531. /**
  16532. * Specifies that the submesh is ready to be used
  16533. * @param mesh defines the mesh to check
  16534. * @param subMesh defines which submesh to check
  16535. * @param useInstances specifies that instances should be used
  16536. * @returns a boolean indicating that the submesh is ready or not
  16537. */
  16538. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  16539. /**
  16540. * Checks if the material is ready to render the requested mesh
  16541. * @param mesh Define the mesh to render
  16542. * @param useInstances Define whether or not the material is used with instances
  16543. * @returns true if ready, otherwise false
  16544. */
  16545. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16546. /**
  16547. * Binds the world matrix to the material
  16548. * @param world defines the world transformation matrix
  16549. * @param effectOverride - If provided, use this effect instead of internal effect
  16550. */
  16551. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16552. /**
  16553. * Binds the submesh to this material by preparing the effect and shader to draw
  16554. * @param world defines the world transformation matrix
  16555. * @param mesh defines the mesh containing the submesh
  16556. * @param subMesh defines the submesh to bind the material to
  16557. */
  16558. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16559. /**
  16560. * Binds the material to the mesh
  16561. * @param world defines the world transformation matrix
  16562. * @param mesh defines the mesh to bind the material to
  16563. * @param effectOverride - If provided, use this effect instead of internal effect
  16564. */
  16565. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16566. protected _afterBind(mesh?: Mesh): void;
  16567. /**
  16568. * Gets the active textures from the material
  16569. * @returns an array of textures
  16570. */
  16571. getActiveTextures(): BaseTexture[];
  16572. /**
  16573. * Specifies if the material uses a texture
  16574. * @param texture defines the texture to check against the material
  16575. * @returns a boolean specifying if the material uses the texture
  16576. */
  16577. hasTexture(texture: BaseTexture): boolean;
  16578. /**
  16579. * Makes a duplicate of the material, and gives it a new name
  16580. * @param name defines the new name for the duplicated material
  16581. * @returns the cloned material
  16582. */
  16583. clone(name: string): ShaderMaterial;
  16584. /**
  16585. * Disposes the material
  16586. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16587. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16588. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16589. */
  16590. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16591. /**
  16592. * Serializes this material in a JSON representation
  16593. * @returns the serialized material object
  16594. */
  16595. serialize(): any;
  16596. /**
  16597. * Creates a shader material from parsed shader material data
  16598. * @param source defines the JSON represnetation of the material
  16599. * @param scene defines the hosting scene
  16600. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16601. * @returns a new material
  16602. */
  16603. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16604. }
  16605. }
  16606. declare module BABYLON {
  16607. /** @hidden */
  16608. export var colorPixelShader: {
  16609. name: string;
  16610. shader: string;
  16611. };
  16612. }
  16613. declare module BABYLON {
  16614. /** @hidden */
  16615. export var colorVertexShader: {
  16616. name: string;
  16617. shader: string;
  16618. };
  16619. }
  16620. declare module BABYLON {
  16621. /**
  16622. * Line mesh
  16623. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16624. */
  16625. export class LinesMesh extends Mesh {
  16626. /**
  16627. * If vertex color should be applied to the mesh
  16628. */
  16629. readonly useVertexColor?: boolean | undefined;
  16630. /**
  16631. * If vertex alpha should be applied to the mesh
  16632. */
  16633. readonly useVertexAlpha?: boolean | undefined;
  16634. /**
  16635. * Color of the line (Default: White)
  16636. */
  16637. color: Color3;
  16638. /**
  16639. * Alpha of the line (Default: 1)
  16640. */
  16641. alpha: number;
  16642. /**
  16643. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16644. * This margin is expressed in world space coordinates, so its value may vary.
  16645. * Default value is 0.1
  16646. */
  16647. intersectionThreshold: number;
  16648. private _colorShader;
  16649. private color4;
  16650. /**
  16651. * Creates a new LinesMesh
  16652. * @param name defines the name
  16653. * @param scene defines the hosting scene
  16654. * @param parent defines the parent mesh if any
  16655. * @param source defines the optional source LinesMesh used to clone data from
  16656. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16657. * When false, achieved by calling a clone(), also passing False.
  16658. * This will make creation of children, recursive.
  16659. * @param useVertexColor defines if this LinesMesh supports vertex color
  16660. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16661. */
  16662. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16663. /**
  16664. * If vertex color should be applied to the mesh
  16665. */
  16666. useVertexColor?: boolean | undefined,
  16667. /**
  16668. * If vertex alpha should be applied to the mesh
  16669. */
  16670. useVertexAlpha?: boolean | undefined);
  16671. private _addClipPlaneDefine;
  16672. private _removeClipPlaneDefine;
  16673. isReady(): boolean;
  16674. /**
  16675. * Returns the string "LineMesh"
  16676. */
  16677. getClassName(): string;
  16678. /**
  16679. * @hidden
  16680. */
  16681. get material(): Material;
  16682. /**
  16683. * @hidden
  16684. */
  16685. set material(value: Material);
  16686. /**
  16687. * @hidden
  16688. */
  16689. get checkCollisions(): boolean;
  16690. /** @hidden */
  16691. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16692. /** @hidden */
  16693. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16694. /**
  16695. * Disposes of the line mesh
  16696. * @param doNotRecurse If children should be disposed
  16697. */
  16698. dispose(doNotRecurse?: boolean): void;
  16699. /**
  16700. * Returns a new LineMesh object cloned from the current one.
  16701. */
  16702. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16703. /**
  16704. * Creates a new InstancedLinesMesh object from the mesh model.
  16705. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16706. * @param name defines the name of the new instance
  16707. * @returns a new InstancedLinesMesh
  16708. */
  16709. createInstance(name: string): InstancedLinesMesh;
  16710. }
  16711. /**
  16712. * Creates an instance based on a source LinesMesh
  16713. */
  16714. export class InstancedLinesMesh extends InstancedMesh {
  16715. /**
  16716. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16717. * This margin is expressed in world space coordinates, so its value may vary.
  16718. * Initilized with the intersectionThreshold value of the source LinesMesh
  16719. */
  16720. intersectionThreshold: number;
  16721. constructor(name: string, source: LinesMesh);
  16722. /**
  16723. * Returns the string "InstancedLinesMesh".
  16724. */
  16725. getClassName(): string;
  16726. }
  16727. }
  16728. declare module BABYLON {
  16729. /** @hidden */
  16730. export var linePixelShader: {
  16731. name: string;
  16732. shader: string;
  16733. };
  16734. }
  16735. declare module BABYLON {
  16736. /** @hidden */
  16737. export var lineVertexShader: {
  16738. name: string;
  16739. shader: string;
  16740. };
  16741. }
  16742. declare module BABYLON {
  16743. interface AbstractMesh {
  16744. /**
  16745. * Gets the edgesRenderer associated with the mesh
  16746. */
  16747. edgesRenderer: Nullable<EdgesRenderer>;
  16748. }
  16749. interface LinesMesh {
  16750. /**
  16751. * Enables the edge rendering mode on the mesh.
  16752. * This mode makes the mesh edges visible
  16753. * @param epsilon defines the maximal distance between two angles to detect a face
  16754. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16755. * @returns the currentAbstractMesh
  16756. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16757. */
  16758. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16759. }
  16760. interface InstancedLinesMesh {
  16761. /**
  16762. * Enables the edge rendering mode on the mesh.
  16763. * This mode makes the mesh edges visible
  16764. * @param epsilon defines the maximal distance between two angles to detect a face
  16765. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16766. * @returns the current InstancedLinesMesh
  16767. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16768. */
  16769. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16770. }
  16771. /**
  16772. * Defines the minimum contract an Edges renderer should follow.
  16773. */
  16774. export interface IEdgesRenderer extends IDisposable {
  16775. /**
  16776. * Gets or sets a boolean indicating if the edgesRenderer is active
  16777. */
  16778. isEnabled: boolean;
  16779. /**
  16780. * Renders the edges of the attached mesh,
  16781. */
  16782. render(): void;
  16783. /**
  16784. * Checks wether or not the edges renderer is ready to render.
  16785. * @return true if ready, otherwise false.
  16786. */
  16787. isReady(): boolean;
  16788. }
  16789. /**
  16790. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16791. */
  16792. export class EdgesRenderer implements IEdgesRenderer {
  16793. /**
  16794. * Define the size of the edges with an orthographic camera
  16795. */
  16796. edgesWidthScalerForOrthographic: number;
  16797. /**
  16798. * Define the size of the edges with a perspective camera
  16799. */
  16800. edgesWidthScalerForPerspective: number;
  16801. protected _source: AbstractMesh;
  16802. protected _linesPositions: number[];
  16803. protected _linesNormals: number[];
  16804. protected _linesIndices: number[];
  16805. protected _epsilon: number;
  16806. protected _indicesCount: number;
  16807. protected _lineShader: ShaderMaterial;
  16808. protected _ib: DataBuffer;
  16809. protected _buffers: {
  16810. [key: string]: Nullable<VertexBuffer>;
  16811. };
  16812. protected _checkVerticesInsteadOfIndices: boolean;
  16813. private _meshRebuildObserver;
  16814. private _meshDisposeObserver;
  16815. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16816. isEnabled: boolean;
  16817. /**
  16818. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16819. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16820. * @param source Mesh used to create edges
  16821. * @param epsilon sum of angles in adjacency to check for edge
  16822. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16823. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16824. */
  16825. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16826. protected _prepareRessources(): void;
  16827. /** @hidden */
  16828. _rebuild(): void;
  16829. /**
  16830. * Releases the required resources for the edges renderer
  16831. */
  16832. dispose(): void;
  16833. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16834. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16835. /**
  16836. * Checks if the pair of p0 and p1 is en edge
  16837. * @param faceIndex
  16838. * @param edge
  16839. * @param faceNormals
  16840. * @param p0
  16841. * @param p1
  16842. * @private
  16843. */
  16844. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16845. /**
  16846. * push line into the position, normal and index buffer
  16847. * @protected
  16848. */
  16849. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16850. /**
  16851. * Generates lines edges from adjacencjes
  16852. * @private
  16853. */
  16854. _generateEdgesLines(): void;
  16855. /**
  16856. * Checks wether or not the edges renderer is ready to render.
  16857. * @return true if ready, otherwise false.
  16858. */
  16859. isReady(): boolean;
  16860. /**
  16861. * Renders the edges of the attached mesh,
  16862. */
  16863. render(): void;
  16864. }
  16865. /**
  16866. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16867. */
  16868. export class LineEdgesRenderer extends EdgesRenderer {
  16869. /**
  16870. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16871. * @param source LineMesh used to generate edges
  16872. * @param epsilon not important (specified angle for edge detection)
  16873. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16874. */
  16875. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16876. /**
  16877. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16878. */
  16879. _generateEdgesLines(): void;
  16880. }
  16881. }
  16882. declare module BABYLON {
  16883. /**
  16884. * This represents the object necessary to create a rendering group.
  16885. * This is exclusively used and created by the rendering manager.
  16886. * To modify the behavior, you use the available helpers in your scene or meshes.
  16887. * @hidden
  16888. */
  16889. export class RenderingGroup {
  16890. index: number;
  16891. private static _zeroVector;
  16892. private _scene;
  16893. private _opaqueSubMeshes;
  16894. private _transparentSubMeshes;
  16895. private _alphaTestSubMeshes;
  16896. private _depthOnlySubMeshes;
  16897. private _particleSystems;
  16898. private _spriteManagers;
  16899. private _opaqueSortCompareFn;
  16900. private _alphaTestSortCompareFn;
  16901. private _transparentSortCompareFn;
  16902. private _renderOpaque;
  16903. private _renderAlphaTest;
  16904. private _renderTransparent;
  16905. /** @hidden */
  16906. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16907. onBeforeTransparentRendering: () => void;
  16908. /**
  16909. * Set the opaque sort comparison function.
  16910. * If null the sub meshes will be render in the order they were created
  16911. */
  16912. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16913. /**
  16914. * Set the alpha test sort comparison function.
  16915. * If null the sub meshes will be render in the order they were created
  16916. */
  16917. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16918. /**
  16919. * Set the transparent sort comparison function.
  16920. * If null the sub meshes will be render in the order they were created
  16921. */
  16922. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16923. /**
  16924. * Creates a new rendering group.
  16925. * @param index The rendering group index
  16926. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16927. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16928. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16929. */
  16930. 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>);
  16931. /**
  16932. * Render all the sub meshes contained in the group.
  16933. * @param customRenderFunction Used to override the default render behaviour of the group.
  16934. * @returns true if rendered some submeshes.
  16935. */
  16936. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16937. /**
  16938. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16939. * @param subMeshes The submeshes to render
  16940. */
  16941. private renderOpaqueSorted;
  16942. /**
  16943. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16944. * @param subMeshes The submeshes to render
  16945. */
  16946. private renderAlphaTestSorted;
  16947. /**
  16948. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16949. * @param subMeshes The submeshes to render
  16950. */
  16951. private renderTransparentSorted;
  16952. /**
  16953. * Renders the submeshes in a specified order.
  16954. * @param subMeshes The submeshes to sort before render
  16955. * @param sortCompareFn The comparison function use to sort
  16956. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16957. * @param transparent Specifies to activate blending if true
  16958. */
  16959. private static renderSorted;
  16960. /**
  16961. * Renders the submeshes in the order they were dispatched (no sort applied).
  16962. * @param subMeshes The submeshes to render
  16963. */
  16964. private static renderUnsorted;
  16965. /**
  16966. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16967. * are rendered back to front if in the same alpha index.
  16968. *
  16969. * @param a The first submesh
  16970. * @param b The second submesh
  16971. * @returns The result of the comparison
  16972. */
  16973. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16974. /**
  16975. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16976. * are rendered back to front.
  16977. *
  16978. * @param a The first submesh
  16979. * @param b The second submesh
  16980. * @returns The result of the comparison
  16981. */
  16982. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16983. /**
  16984. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16985. * are rendered front to back (prevent overdraw).
  16986. *
  16987. * @param a The first submesh
  16988. * @param b The second submesh
  16989. * @returns The result of the comparison
  16990. */
  16991. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16992. /**
  16993. * Resets the different lists of submeshes to prepare a new frame.
  16994. */
  16995. prepare(): void;
  16996. dispose(): void;
  16997. /**
  16998. * Inserts the submesh in its correct queue depending on its material.
  16999. * @param subMesh The submesh to dispatch
  17000. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17001. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17002. */
  17003. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17004. dispatchSprites(spriteManager: ISpriteManager): void;
  17005. dispatchParticles(particleSystem: IParticleSystem): void;
  17006. private _renderParticles;
  17007. private _renderSprites;
  17008. }
  17009. }
  17010. declare module BABYLON {
  17011. /**
  17012. * Interface describing the different options available in the rendering manager
  17013. * regarding Auto Clear between groups.
  17014. */
  17015. export interface IRenderingManagerAutoClearSetup {
  17016. /**
  17017. * Defines whether or not autoclear is enable.
  17018. */
  17019. autoClear: boolean;
  17020. /**
  17021. * Defines whether or not to autoclear the depth buffer.
  17022. */
  17023. depth: boolean;
  17024. /**
  17025. * Defines whether or not to autoclear the stencil buffer.
  17026. */
  17027. stencil: boolean;
  17028. }
  17029. /**
  17030. * This class is used by the onRenderingGroupObservable
  17031. */
  17032. export class RenderingGroupInfo {
  17033. /**
  17034. * The Scene that being rendered
  17035. */
  17036. scene: Scene;
  17037. /**
  17038. * The camera currently used for the rendering pass
  17039. */
  17040. camera: Nullable<Camera>;
  17041. /**
  17042. * The ID of the renderingGroup being processed
  17043. */
  17044. renderingGroupId: number;
  17045. }
  17046. /**
  17047. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17048. * It is enable to manage the different groups as well as the different necessary sort functions.
  17049. * This should not be used directly aside of the few static configurations
  17050. */
  17051. export class RenderingManager {
  17052. /**
  17053. * The max id used for rendering groups (not included)
  17054. */
  17055. static MAX_RENDERINGGROUPS: number;
  17056. /**
  17057. * The min id used for rendering groups (included)
  17058. */
  17059. static MIN_RENDERINGGROUPS: number;
  17060. /**
  17061. * Used to globally prevent autoclearing scenes.
  17062. */
  17063. static AUTOCLEAR: boolean;
  17064. /**
  17065. * @hidden
  17066. */
  17067. _useSceneAutoClearSetup: boolean;
  17068. private _scene;
  17069. private _renderingGroups;
  17070. private _depthStencilBufferAlreadyCleaned;
  17071. private _autoClearDepthStencil;
  17072. private _customOpaqueSortCompareFn;
  17073. private _customAlphaTestSortCompareFn;
  17074. private _customTransparentSortCompareFn;
  17075. private _renderingGroupInfo;
  17076. /**
  17077. * Instantiates a new rendering group for a particular scene
  17078. * @param scene Defines the scene the groups belongs to
  17079. */
  17080. constructor(scene: Scene);
  17081. private _clearDepthStencilBuffer;
  17082. /**
  17083. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17084. * @hidden
  17085. */
  17086. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17087. /**
  17088. * Resets the different information of the group to prepare a new frame
  17089. * @hidden
  17090. */
  17091. reset(): void;
  17092. /**
  17093. * Dispose and release the group and its associated resources.
  17094. * @hidden
  17095. */
  17096. dispose(): void;
  17097. /**
  17098. * Clear the info related to rendering groups preventing retention points during dispose.
  17099. */
  17100. freeRenderingGroups(): void;
  17101. private _prepareRenderingGroup;
  17102. /**
  17103. * Add a sprite manager to the rendering manager in order to render it this frame.
  17104. * @param spriteManager Define the sprite manager to render
  17105. */
  17106. dispatchSprites(spriteManager: ISpriteManager): void;
  17107. /**
  17108. * Add a particle system to the rendering manager in order to render it this frame.
  17109. * @param particleSystem Define the particle system to render
  17110. */
  17111. dispatchParticles(particleSystem: IParticleSystem): void;
  17112. /**
  17113. * Add a submesh to the manager in order to render it this frame
  17114. * @param subMesh The submesh to dispatch
  17115. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17116. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17117. */
  17118. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17119. /**
  17120. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17121. * This allowed control for front to back rendering or reversly depending of the special needs.
  17122. *
  17123. * @param renderingGroupId The rendering group id corresponding to its index
  17124. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17125. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17126. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17127. */
  17128. 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;
  17129. /**
  17130. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17131. *
  17132. * @param renderingGroupId The rendering group id corresponding to its index
  17133. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17134. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17135. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17136. */
  17137. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17138. /**
  17139. * Gets the current auto clear configuration for one rendering group of the rendering
  17140. * manager.
  17141. * @param index the rendering group index to get the information for
  17142. * @returns The auto clear setup for the requested rendering group
  17143. */
  17144. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17145. }
  17146. }
  17147. declare module BABYLON {
  17148. /**
  17149. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17150. */
  17151. export interface ICustomShaderOptions {
  17152. /**
  17153. * Gets or sets the custom shader name to use
  17154. */
  17155. shaderName: string;
  17156. /**
  17157. * The list of attribute names used in the shader
  17158. */
  17159. attributes?: string[];
  17160. /**
  17161. * The list of unifrom names used in the shader
  17162. */
  17163. uniforms?: string[];
  17164. /**
  17165. * The list of sampler names used in the shader
  17166. */
  17167. samplers?: string[];
  17168. /**
  17169. * The list of defines used in the shader
  17170. */
  17171. defines?: string[];
  17172. }
  17173. /**
  17174. * Interface to implement to create a shadow generator compatible with BJS.
  17175. */
  17176. export interface IShadowGenerator {
  17177. /**
  17178. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17179. * @returns The render target texture if present otherwise, null
  17180. */
  17181. getShadowMap(): Nullable<RenderTargetTexture>;
  17182. /**
  17183. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17184. * @param subMesh The submesh we want to render in the shadow map
  17185. * @param useInstances Defines wether will draw in the map using instances
  17186. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17187. * @returns true if ready otherwise, false
  17188. */
  17189. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17190. /**
  17191. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17192. * @param defines Defines of the material we want to update
  17193. * @param lightIndex Index of the light in the enabled light list of the material
  17194. */
  17195. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17196. /**
  17197. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17198. * defined in the generator but impacting the effect).
  17199. * It implies the unifroms available on the materials are the standard BJS ones.
  17200. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17201. * @param effect The effect we are binfing the information for
  17202. */
  17203. bindShadowLight(lightIndex: string, effect: Effect): void;
  17204. /**
  17205. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17206. * (eq to shadow prjection matrix * light transform matrix)
  17207. * @returns The transform matrix used to create the shadow map
  17208. */
  17209. getTransformMatrix(): Matrix;
  17210. /**
  17211. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17212. * Cube and 2D textures for instance.
  17213. */
  17214. recreateShadowMap(): void;
  17215. /**
  17216. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17217. * @param onCompiled Callback triggered at the and of the effects compilation
  17218. * @param options Sets of optional options forcing the compilation with different modes
  17219. */
  17220. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17221. useInstances: boolean;
  17222. }>): void;
  17223. /**
  17224. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17225. * @param options Sets of optional options forcing the compilation with different modes
  17226. * @returns A promise that resolves when the compilation completes
  17227. */
  17228. forceCompilationAsync(options?: Partial<{
  17229. useInstances: boolean;
  17230. }>): Promise<void>;
  17231. /**
  17232. * Serializes the shadow generator setup to a json object.
  17233. * @returns The serialized JSON object
  17234. */
  17235. serialize(): any;
  17236. /**
  17237. * Disposes the Shadow map and related Textures and effects.
  17238. */
  17239. dispose(): void;
  17240. }
  17241. /**
  17242. * Default implementation IShadowGenerator.
  17243. * This is the main object responsible of generating shadows in the framework.
  17244. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17245. */
  17246. export class ShadowGenerator implements IShadowGenerator {
  17247. /**
  17248. * Name of the shadow generator class
  17249. */
  17250. static CLASSNAME: string;
  17251. /**
  17252. * Shadow generator mode None: no filtering applied.
  17253. */
  17254. static readonly FILTER_NONE: number;
  17255. /**
  17256. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17257. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17258. */
  17259. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17260. /**
  17261. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17262. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17263. */
  17264. static readonly FILTER_POISSONSAMPLING: number;
  17265. /**
  17266. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17267. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17268. */
  17269. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17270. /**
  17271. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17272. * edge artifacts on steep falloff.
  17273. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17274. */
  17275. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17276. /**
  17277. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17278. * edge artifacts on steep falloff.
  17279. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17280. */
  17281. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17282. /**
  17283. * Shadow generator mode PCF: Percentage Closer Filtering
  17284. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17285. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17286. */
  17287. static readonly FILTER_PCF: number;
  17288. /**
  17289. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17290. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17291. * Contact Hardening
  17292. */
  17293. static readonly FILTER_PCSS: number;
  17294. /**
  17295. * Reserved for PCF and PCSS
  17296. * Highest Quality.
  17297. *
  17298. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17299. *
  17300. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17301. */
  17302. static readonly QUALITY_HIGH: number;
  17303. /**
  17304. * Reserved for PCF and PCSS
  17305. * Good tradeoff for quality/perf cross devices
  17306. *
  17307. * Execute PCF on a 3*3 kernel.
  17308. *
  17309. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17310. */
  17311. static readonly QUALITY_MEDIUM: number;
  17312. /**
  17313. * Reserved for PCF and PCSS
  17314. * The lowest quality but the fastest.
  17315. *
  17316. * Execute PCF on a 1*1 kernel.
  17317. *
  17318. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17319. */
  17320. static readonly QUALITY_LOW: number;
  17321. /** Gets or sets the custom shader name to use */
  17322. customShaderOptions: ICustomShaderOptions;
  17323. /**
  17324. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17325. */
  17326. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17327. /**
  17328. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17329. */
  17330. onAfterShadowMapRenderObservable: Observable<Effect>;
  17331. /**
  17332. * Observable triggered before a mesh is rendered in the shadow map.
  17333. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17334. */
  17335. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17336. /**
  17337. * Observable triggered after a mesh is rendered in the shadow map.
  17338. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17339. */
  17340. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17341. protected _bias: number;
  17342. /**
  17343. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17344. */
  17345. get bias(): number;
  17346. /**
  17347. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17348. */
  17349. set bias(bias: number);
  17350. protected _normalBias: number;
  17351. /**
  17352. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17353. */
  17354. get normalBias(): number;
  17355. /**
  17356. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17357. */
  17358. set normalBias(normalBias: number);
  17359. protected _blurBoxOffset: number;
  17360. /**
  17361. * Gets the blur box offset: offset applied during the blur pass.
  17362. * Only useful if useKernelBlur = false
  17363. */
  17364. get blurBoxOffset(): number;
  17365. /**
  17366. * Sets the blur box offset: offset applied during the blur pass.
  17367. * Only useful if useKernelBlur = false
  17368. */
  17369. set blurBoxOffset(value: number);
  17370. protected _blurScale: number;
  17371. /**
  17372. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17373. * 2 means half of the size.
  17374. */
  17375. get blurScale(): number;
  17376. /**
  17377. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17378. * 2 means half of the size.
  17379. */
  17380. set blurScale(value: number);
  17381. protected _blurKernel: number;
  17382. /**
  17383. * Gets the blur kernel: kernel size of the blur pass.
  17384. * Only useful if useKernelBlur = true
  17385. */
  17386. get blurKernel(): number;
  17387. /**
  17388. * Sets the blur kernel: kernel size of the blur pass.
  17389. * Only useful if useKernelBlur = true
  17390. */
  17391. set blurKernel(value: number);
  17392. protected _useKernelBlur: boolean;
  17393. /**
  17394. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17395. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17396. */
  17397. get useKernelBlur(): boolean;
  17398. /**
  17399. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17400. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17401. */
  17402. set useKernelBlur(value: boolean);
  17403. protected _depthScale: number;
  17404. /**
  17405. * Gets the depth scale used in ESM mode.
  17406. */
  17407. get depthScale(): number;
  17408. /**
  17409. * Sets the depth scale used in ESM mode.
  17410. * This can override the scale stored on the light.
  17411. */
  17412. set depthScale(value: number);
  17413. protected _validateFilter(filter: number): number;
  17414. protected _filter: number;
  17415. /**
  17416. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17417. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17418. */
  17419. get filter(): number;
  17420. /**
  17421. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17422. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17423. */
  17424. set filter(value: number);
  17425. /**
  17426. * Gets if the current filter is set to Poisson Sampling.
  17427. */
  17428. get usePoissonSampling(): boolean;
  17429. /**
  17430. * Sets the current filter to Poisson Sampling.
  17431. */
  17432. set usePoissonSampling(value: boolean);
  17433. /**
  17434. * Gets if the current filter is set to ESM.
  17435. */
  17436. get useExponentialShadowMap(): boolean;
  17437. /**
  17438. * Sets the current filter is to ESM.
  17439. */
  17440. set useExponentialShadowMap(value: boolean);
  17441. /**
  17442. * Gets if the current filter is set to filtered ESM.
  17443. */
  17444. get useBlurExponentialShadowMap(): boolean;
  17445. /**
  17446. * Gets if the current filter is set to filtered ESM.
  17447. */
  17448. set useBlurExponentialShadowMap(value: boolean);
  17449. /**
  17450. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17451. * exponential to prevent steep falloff artifacts).
  17452. */
  17453. get useCloseExponentialShadowMap(): boolean;
  17454. /**
  17455. * Sets the current filter to "close ESM" (using the inverse of the
  17456. * exponential to prevent steep falloff artifacts).
  17457. */
  17458. set useCloseExponentialShadowMap(value: boolean);
  17459. /**
  17460. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17461. * exponential to prevent steep falloff artifacts).
  17462. */
  17463. get useBlurCloseExponentialShadowMap(): boolean;
  17464. /**
  17465. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17466. * exponential to prevent steep falloff artifacts).
  17467. */
  17468. set useBlurCloseExponentialShadowMap(value: boolean);
  17469. /**
  17470. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17471. */
  17472. get usePercentageCloserFiltering(): boolean;
  17473. /**
  17474. * Sets the current filter to "PCF" (percentage closer filtering).
  17475. */
  17476. set usePercentageCloserFiltering(value: boolean);
  17477. protected _filteringQuality: number;
  17478. /**
  17479. * Gets the PCF or PCSS Quality.
  17480. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17481. */
  17482. get filteringQuality(): number;
  17483. /**
  17484. * Sets the PCF or PCSS Quality.
  17485. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17486. */
  17487. set filteringQuality(filteringQuality: number);
  17488. /**
  17489. * Gets if the current filter is set to "PCSS" (contact hardening).
  17490. */
  17491. get useContactHardeningShadow(): boolean;
  17492. /**
  17493. * Sets the current filter to "PCSS" (contact hardening).
  17494. */
  17495. set useContactHardeningShadow(value: boolean);
  17496. protected _contactHardeningLightSizeUVRatio: number;
  17497. /**
  17498. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17499. * Using a ratio helps keeping shape stability independently of the map size.
  17500. *
  17501. * It does not account for the light projection as it was having too much
  17502. * instability during the light setup or during light position changes.
  17503. *
  17504. * Only valid if useContactHardeningShadow is true.
  17505. */
  17506. get contactHardeningLightSizeUVRatio(): number;
  17507. /**
  17508. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17509. * Using a ratio helps keeping shape stability independently of the map size.
  17510. *
  17511. * It does not account for the light projection as it was having too much
  17512. * instability during the light setup or during light position changes.
  17513. *
  17514. * Only valid if useContactHardeningShadow is true.
  17515. */
  17516. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17517. protected _darkness: number;
  17518. /** Gets or sets the actual darkness of a shadow */
  17519. get darkness(): number;
  17520. set darkness(value: number);
  17521. /**
  17522. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17523. * 0 means strongest and 1 would means no shadow.
  17524. * @returns the darkness.
  17525. */
  17526. getDarkness(): number;
  17527. /**
  17528. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17529. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17530. * @returns the shadow generator allowing fluent coding.
  17531. */
  17532. setDarkness(darkness: number): ShadowGenerator;
  17533. protected _transparencyShadow: boolean;
  17534. /** Gets or sets the ability to have transparent shadow */
  17535. get transparencyShadow(): boolean;
  17536. set transparencyShadow(value: boolean);
  17537. /**
  17538. * Sets the ability to have transparent shadow (boolean).
  17539. * @param transparent True if transparent else False
  17540. * @returns the shadow generator allowing fluent coding
  17541. */
  17542. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17543. /**
  17544. * Enables or disables shadows with varying strength based on the transparency
  17545. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17546. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17547. * mesh.visibility * alphaTexture.a
  17548. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17549. */
  17550. enableSoftTransparentShadow: boolean;
  17551. protected _shadowMap: Nullable<RenderTargetTexture>;
  17552. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17553. /**
  17554. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17555. * @returns The render target texture if present otherwise, null
  17556. */
  17557. getShadowMap(): Nullable<RenderTargetTexture>;
  17558. /**
  17559. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17560. * @returns The render target texture if the shadow map is present otherwise, null
  17561. */
  17562. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17563. /**
  17564. * Gets the class name of that object
  17565. * @returns "ShadowGenerator"
  17566. */
  17567. getClassName(): string;
  17568. /**
  17569. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17570. * @param mesh Mesh to add
  17571. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17572. * @returns the Shadow Generator itself
  17573. */
  17574. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17575. /**
  17576. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17577. * @param mesh Mesh to remove
  17578. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17579. * @returns the Shadow Generator itself
  17580. */
  17581. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17582. /**
  17583. * Controls the extent to which the shadows fade out at the edge of the frustum
  17584. */
  17585. frustumEdgeFalloff: number;
  17586. protected _light: IShadowLight;
  17587. /**
  17588. * Returns the associated light object.
  17589. * @returns the light generating the shadow
  17590. */
  17591. getLight(): IShadowLight;
  17592. /**
  17593. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17594. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17595. * It might on the other hand introduce peter panning.
  17596. */
  17597. forceBackFacesOnly: boolean;
  17598. protected _scene: Scene;
  17599. protected _lightDirection: Vector3;
  17600. protected _effect: Effect;
  17601. protected _viewMatrix: Matrix;
  17602. protected _projectionMatrix: Matrix;
  17603. protected _transformMatrix: Matrix;
  17604. protected _cachedPosition: Vector3;
  17605. protected _cachedDirection: Vector3;
  17606. protected _cachedDefines: string;
  17607. protected _currentRenderID: number;
  17608. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17609. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17610. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17611. protected _blurPostProcesses: PostProcess[];
  17612. protected _mapSize: number;
  17613. protected _currentFaceIndex: number;
  17614. protected _currentFaceIndexCache: number;
  17615. protected _textureType: number;
  17616. protected _defaultTextureMatrix: Matrix;
  17617. protected _storedUniqueId: Nullable<number>;
  17618. /** @hidden */
  17619. static _SceneComponentInitialization: (scene: Scene) => void;
  17620. /**
  17621. * Creates a ShadowGenerator object.
  17622. * A ShadowGenerator is the required tool to use the shadows.
  17623. * Each light casting shadows needs to use its own ShadowGenerator.
  17624. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17625. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17626. * @param light The light object generating the shadows.
  17627. * @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.
  17628. */
  17629. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17630. protected _initializeGenerator(): void;
  17631. protected _createTargetRenderTexture(): void;
  17632. protected _initializeShadowMap(): void;
  17633. protected _initializeBlurRTTAndPostProcesses(): void;
  17634. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17635. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17636. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  17637. protected _applyFilterValues(): void;
  17638. /**
  17639. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17640. * @param onCompiled Callback triggered at the and of the effects compilation
  17641. * @param options Sets of optional options forcing the compilation with different modes
  17642. */
  17643. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17644. useInstances: boolean;
  17645. }>): void;
  17646. /**
  17647. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17648. * @param options Sets of optional options forcing the compilation with different modes
  17649. * @returns A promise that resolves when the compilation completes
  17650. */
  17651. forceCompilationAsync(options?: Partial<{
  17652. useInstances: boolean;
  17653. }>): Promise<void>;
  17654. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17655. private _prepareShadowDefines;
  17656. /**
  17657. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17658. * @param subMesh The submesh we want to render in the shadow map
  17659. * @param useInstances Defines wether will draw in the map using instances
  17660. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17661. * @returns true if ready otherwise, false
  17662. */
  17663. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17664. /**
  17665. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17666. * @param defines Defines of the material we want to update
  17667. * @param lightIndex Index of the light in the enabled light list of the material
  17668. */
  17669. prepareDefines(defines: any, lightIndex: number): void;
  17670. /**
  17671. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17672. * defined in the generator but impacting the effect).
  17673. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17674. * @param effect The effect we are binfing the information for
  17675. */
  17676. bindShadowLight(lightIndex: string, effect: Effect): void;
  17677. /**
  17678. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17679. * (eq to shadow prjection matrix * light transform matrix)
  17680. * @returns The transform matrix used to create the shadow map
  17681. */
  17682. getTransformMatrix(): Matrix;
  17683. /**
  17684. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17685. * Cube and 2D textures for instance.
  17686. */
  17687. recreateShadowMap(): void;
  17688. protected _disposeBlurPostProcesses(): void;
  17689. protected _disposeRTTandPostProcesses(): void;
  17690. /**
  17691. * Disposes the ShadowGenerator.
  17692. * Returns nothing.
  17693. */
  17694. dispose(): void;
  17695. /**
  17696. * Serializes the shadow generator setup to a json object.
  17697. * @returns The serialized JSON object
  17698. */
  17699. serialize(): any;
  17700. /**
  17701. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17702. * @param parsedShadowGenerator The JSON object to parse
  17703. * @param scene The scene to create the shadow map for
  17704. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17705. * @returns The parsed shadow generator
  17706. */
  17707. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17708. }
  17709. }
  17710. declare module BABYLON {
  17711. /**
  17712. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17713. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17714. * 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.
  17715. */
  17716. export abstract class Light extends Node {
  17717. /**
  17718. * Falloff Default: light is falling off following the material specification:
  17719. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17720. */
  17721. static readonly FALLOFF_DEFAULT: number;
  17722. /**
  17723. * Falloff Physical: light is falling off following the inverse squared distance law.
  17724. */
  17725. static readonly FALLOFF_PHYSICAL: number;
  17726. /**
  17727. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17728. * to enhance interoperability with other engines.
  17729. */
  17730. static readonly FALLOFF_GLTF: number;
  17731. /**
  17732. * Falloff Standard: light is falling off like in the standard material
  17733. * to enhance interoperability with other materials.
  17734. */
  17735. static readonly FALLOFF_STANDARD: number;
  17736. /**
  17737. * If every light affecting the material is in this lightmapMode,
  17738. * material.lightmapTexture adds or multiplies
  17739. * (depends on material.useLightmapAsShadowmap)
  17740. * after every other light calculations.
  17741. */
  17742. static readonly LIGHTMAP_DEFAULT: number;
  17743. /**
  17744. * material.lightmapTexture as only diffuse lighting from this light
  17745. * adds only specular lighting from this light
  17746. * adds dynamic shadows
  17747. */
  17748. static readonly LIGHTMAP_SPECULAR: number;
  17749. /**
  17750. * material.lightmapTexture as only lighting
  17751. * no light calculation from this light
  17752. * only adds dynamic shadows from this light
  17753. */
  17754. static readonly LIGHTMAP_SHADOWSONLY: number;
  17755. /**
  17756. * Each light type uses the default quantity according to its type:
  17757. * point/spot lights use luminous intensity
  17758. * directional lights use illuminance
  17759. */
  17760. static readonly INTENSITYMODE_AUTOMATIC: number;
  17761. /**
  17762. * lumen (lm)
  17763. */
  17764. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17765. /**
  17766. * candela (lm/sr)
  17767. */
  17768. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17769. /**
  17770. * lux (lm/m^2)
  17771. */
  17772. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17773. /**
  17774. * nit (cd/m^2)
  17775. */
  17776. static readonly INTENSITYMODE_LUMINANCE: number;
  17777. /**
  17778. * Light type const id of the point light.
  17779. */
  17780. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17781. /**
  17782. * Light type const id of the directional light.
  17783. */
  17784. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17785. /**
  17786. * Light type const id of the spot light.
  17787. */
  17788. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17789. /**
  17790. * Light type const id of the hemispheric light.
  17791. */
  17792. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17793. /**
  17794. * Diffuse gives the basic color to an object.
  17795. */
  17796. diffuse: Color3;
  17797. /**
  17798. * Specular produces a highlight color on an object.
  17799. * Note: This is note affecting PBR materials.
  17800. */
  17801. specular: Color3;
  17802. /**
  17803. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17804. * falling off base on range or angle.
  17805. * This can be set to any values in Light.FALLOFF_x.
  17806. *
  17807. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17808. * other types of materials.
  17809. */
  17810. falloffType: number;
  17811. /**
  17812. * Strength of the light.
  17813. * Note: By default it is define in the framework own unit.
  17814. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17815. */
  17816. intensity: number;
  17817. private _range;
  17818. protected _inverseSquaredRange: number;
  17819. /**
  17820. * Defines how far from the source the light is impacting in scene units.
  17821. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17822. */
  17823. get range(): number;
  17824. /**
  17825. * Defines how far from the source the light is impacting in scene units.
  17826. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17827. */
  17828. set range(value: number);
  17829. /**
  17830. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17831. * of light.
  17832. */
  17833. private _photometricScale;
  17834. private _intensityMode;
  17835. /**
  17836. * Gets the photometric scale used to interpret the intensity.
  17837. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17838. */
  17839. get intensityMode(): number;
  17840. /**
  17841. * Sets the photometric scale used to interpret the intensity.
  17842. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17843. */
  17844. set intensityMode(value: number);
  17845. private _radius;
  17846. /**
  17847. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17848. */
  17849. get radius(): number;
  17850. /**
  17851. * sets the light radius used by PBR Materials to simulate soft area lights.
  17852. */
  17853. set radius(value: number);
  17854. private _renderPriority;
  17855. /**
  17856. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17857. * exceeding the number allowed of the materials.
  17858. */
  17859. renderPriority: number;
  17860. private _shadowEnabled;
  17861. /**
  17862. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17863. * the current shadow generator.
  17864. */
  17865. get shadowEnabled(): boolean;
  17866. /**
  17867. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17868. * the current shadow generator.
  17869. */
  17870. set shadowEnabled(value: boolean);
  17871. private _includedOnlyMeshes;
  17872. /**
  17873. * Gets the only meshes impacted by this light.
  17874. */
  17875. get includedOnlyMeshes(): AbstractMesh[];
  17876. /**
  17877. * Sets the only meshes impacted by this light.
  17878. */
  17879. set includedOnlyMeshes(value: AbstractMesh[]);
  17880. private _excludedMeshes;
  17881. /**
  17882. * Gets the meshes not impacted by this light.
  17883. */
  17884. get excludedMeshes(): AbstractMesh[];
  17885. /**
  17886. * Sets the meshes not impacted by this light.
  17887. */
  17888. set excludedMeshes(value: AbstractMesh[]);
  17889. private _excludeWithLayerMask;
  17890. /**
  17891. * Gets the layer id use to find what meshes are not impacted by the light.
  17892. * Inactive if 0
  17893. */
  17894. get excludeWithLayerMask(): number;
  17895. /**
  17896. * Sets the layer id use to find what meshes are not impacted by the light.
  17897. * Inactive if 0
  17898. */
  17899. set excludeWithLayerMask(value: number);
  17900. private _includeOnlyWithLayerMask;
  17901. /**
  17902. * Gets the layer id use to find what meshes are impacted by the light.
  17903. * Inactive if 0
  17904. */
  17905. get includeOnlyWithLayerMask(): number;
  17906. /**
  17907. * Sets the layer id use to find what meshes are impacted by the light.
  17908. * Inactive if 0
  17909. */
  17910. set includeOnlyWithLayerMask(value: number);
  17911. private _lightmapMode;
  17912. /**
  17913. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17914. */
  17915. get lightmapMode(): number;
  17916. /**
  17917. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17918. */
  17919. set lightmapMode(value: number);
  17920. /**
  17921. * Shadow generator associted to the light.
  17922. * @hidden Internal use only.
  17923. */
  17924. _shadowGenerator: Nullable<IShadowGenerator>;
  17925. /**
  17926. * @hidden Internal use only.
  17927. */
  17928. _excludedMeshesIds: string[];
  17929. /**
  17930. * @hidden Internal use only.
  17931. */
  17932. _includedOnlyMeshesIds: string[];
  17933. /**
  17934. * The current light unifom buffer.
  17935. * @hidden Internal use only.
  17936. */
  17937. _uniformBuffer: UniformBuffer;
  17938. /** @hidden */
  17939. _renderId: number;
  17940. /**
  17941. * Creates a Light object in the scene.
  17942. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17943. * @param name The firendly name of the light
  17944. * @param scene The scene the light belongs too
  17945. */
  17946. constructor(name: string, scene: Scene);
  17947. protected abstract _buildUniformLayout(): void;
  17948. /**
  17949. * Sets the passed Effect "effect" with the Light information.
  17950. * @param effect The effect to update
  17951. * @param lightIndex The index of the light in the effect to update
  17952. * @returns The light
  17953. */
  17954. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17955. /**
  17956. * Sets the passed Effect "effect" with the Light textures.
  17957. * @param effect The effect to update
  17958. * @param lightIndex The index of the light in the effect to update
  17959. * @returns The light
  17960. */
  17961. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17962. /**
  17963. * Binds the lights information from the scene to the effect for the given mesh.
  17964. * @param lightIndex Light index
  17965. * @param scene The scene where the light belongs to
  17966. * @param effect The effect we are binding the data to
  17967. * @param useSpecular Defines if specular is supported
  17968. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17969. */
  17970. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17971. /**
  17972. * Sets the passed Effect "effect" with the Light information.
  17973. * @param effect The effect to update
  17974. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17975. * @returns The light
  17976. */
  17977. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17978. /**
  17979. * Returns the string "Light".
  17980. * @returns the class name
  17981. */
  17982. getClassName(): string;
  17983. /** @hidden */
  17984. readonly _isLight: boolean;
  17985. /**
  17986. * Converts the light information to a readable string for debug purpose.
  17987. * @param fullDetails Supports for multiple levels of logging within scene loading
  17988. * @returns the human readable light info
  17989. */
  17990. toString(fullDetails?: boolean): string;
  17991. /** @hidden */
  17992. protected _syncParentEnabledState(): void;
  17993. /**
  17994. * Set the enabled state of this node.
  17995. * @param value - the new enabled state
  17996. */
  17997. setEnabled(value: boolean): void;
  17998. /**
  17999. * Returns the Light associated shadow generator if any.
  18000. * @return the associated shadow generator.
  18001. */
  18002. getShadowGenerator(): Nullable<IShadowGenerator>;
  18003. /**
  18004. * Returns a Vector3, the absolute light position in the World.
  18005. * @returns the world space position of the light
  18006. */
  18007. getAbsolutePosition(): Vector3;
  18008. /**
  18009. * Specifies if the light will affect the passed mesh.
  18010. * @param mesh The mesh to test against the light
  18011. * @return true the mesh is affected otherwise, false.
  18012. */
  18013. canAffectMesh(mesh: AbstractMesh): boolean;
  18014. /**
  18015. * Sort function to order lights for rendering.
  18016. * @param a First Light object to compare to second.
  18017. * @param b Second Light object to compare first.
  18018. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18019. */
  18020. static CompareLightsPriority(a: Light, b: Light): number;
  18021. /**
  18022. * Releases resources associated with this node.
  18023. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18024. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18025. */
  18026. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18027. /**
  18028. * Returns the light type ID (integer).
  18029. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18030. */
  18031. getTypeID(): number;
  18032. /**
  18033. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18034. * @returns the scaled intensity in intensity mode unit
  18035. */
  18036. getScaledIntensity(): number;
  18037. /**
  18038. * Returns a new Light object, named "name", from the current one.
  18039. * @param name The name of the cloned light
  18040. * @param newParent The parent of this light, if it has one
  18041. * @returns the new created light
  18042. */
  18043. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18044. /**
  18045. * Serializes the current light into a Serialization object.
  18046. * @returns the serialized object.
  18047. */
  18048. serialize(): any;
  18049. /**
  18050. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18051. * This new light is named "name" and added to the passed scene.
  18052. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18053. * @param name The friendly name of the light
  18054. * @param scene The scene the new light will belong to
  18055. * @returns the constructor function
  18056. */
  18057. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18058. /**
  18059. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18060. * @param parsedLight The JSON representation of the light
  18061. * @param scene The scene to create the parsed light in
  18062. * @returns the created light after parsing
  18063. */
  18064. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18065. private _hookArrayForExcluded;
  18066. private _hookArrayForIncludedOnly;
  18067. private _resyncMeshes;
  18068. /**
  18069. * Forces the meshes to update their light related information in their rendering used effects
  18070. * @hidden Internal Use Only
  18071. */
  18072. _markMeshesAsLightDirty(): void;
  18073. /**
  18074. * Recomputes the cached photometric scale if needed.
  18075. */
  18076. private _computePhotometricScale;
  18077. /**
  18078. * Returns the Photometric Scale according to the light type and intensity mode.
  18079. */
  18080. private _getPhotometricScale;
  18081. /**
  18082. * Reorder the light in the scene according to their defined priority.
  18083. * @hidden Internal Use Only
  18084. */
  18085. _reorderLightsInScene(): void;
  18086. /**
  18087. * Prepares the list of defines specific to the light type.
  18088. * @param defines the list of defines
  18089. * @param lightIndex defines the index of the light for the effect
  18090. */
  18091. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18092. }
  18093. }
  18094. declare module BABYLON {
  18095. /**
  18096. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18097. * This is the base of the follow, arc rotate cameras and Free camera
  18098. * @see http://doc.babylonjs.com/features/cameras
  18099. */
  18100. export class TargetCamera extends Camera {
  18101. private static _RigCamTransformMatrix;
  18102. private static _TargetTransformMatrix;
  18103. private static _TargetFocalPoint;
  18104. /**
  18105. * Define the current direction the camera is moving to
  18106. */
  18107. cameraDirection: Vector3;
  18108. /**
  18109. * Define the current rotation the camera is rotating to
  18110. */
  18111. cameraRotation: Vector2;
  18112. /**
  18113. * When set, the up vector of the camera will be updated by the rotation of the camera
  18114. */
  18115. updateUpVectorFromRotation: boolean;
  18116. private _tmpQuaternion;
  18117. /**
  18118. * Define the current rotation of the camera
  18119. */
  18120. rotation: Vector3;
  18121. /**
  18122. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18123. */
  18124. rotationQuaternion: Quaternion;
  18125. /**
  18126. * Define the current speed of the camera
  18127. */
  18128. speed: number;
  18129. /**
  18130. * Add constraint to the camera to prevent it to move freely in all directions and
  18131. * around all axis.
  18132. */
  18133. noRotationConstraint: boolean;
  18134. /**
  18135. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18136. * panning
  18137. */
  18138. invertRotation: boolean;
  18139. /**
  18140. * Speed multiplier for inverse camera panning
  18141. */
  18142. inverseRotationSpeed: number;
  18143. /**
  18144. * Define the current target of the camera as an object or a position.
  18145. */
  18146. lockedTarget: any;
  18147. /** @hidden */
  18148. _currentTarget: Vector3;
  18149. /** @hidden */
  18150. _initialFocalDistance: number;
  18151. /** @hidden */
  18152. _viewMatrix: Matrix;
  18153. /** @hidden */
  18154. _camMatrix: Matrix;
  18155. /** @hidden */
  18156. _cameraTransformMatrix: Matrix;
  18157. /** @hidden */
  18158. _cameraRotationMatrix: Matrix;
  18159. /** @hidden */
  18160. _referencePoint: Vector3;
  18161. /** @hidden */
  18162. _transformedReferencePoint: Vector3;
  18163. protected _globalCurrentTarget: Vector3;
  18164. protected _globalCurrentUpVector: Vector3;
  18165. /** @hidden */
  18166. _reset: () => void;
  18167. private _defaultUp;
  18168. /**
  18169. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18170. * This is the base of the follow, arc rotate cameras and Free camera
  18171. * @see http://doc.babylonjs.com/features/cameras
  18172. * @param name Defines the name of the camera in the scene
  18173. * @param position Defines the start position of the camera in the scene
  18174. * @param scene Defines the scene the camera belongs to
  18175. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18176. */
  18177. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18178. /**
  18179. * Gets the position in front of the camera at a given distance.
  18180. * @param distance The distance from the camera we want the position to be
  18181. * @returns the position
  18182. */
  18183. getFrontPosition(distance: number): Vector3;
  18184. /** @hidden */
  18185. _getLockedTargetPosition(): Nullable<Vector3>;
  18186. private _storedPosition;
  18187. private _storedRotation;
  18188. private _storedRotationQuaternion;
  18189. /**
  18190. * Store current camera state of the camera (fov, position, rotation, etc..)
  18191. * @returns the camera
  18192. */
  18193. storeState(): Camera;
  18194. /**
  18195. * Restored camera state. You must call storeState() first
  18196. * @returns whether it was successful or not
  18197. * @hidden
  18198. */
  18199. _restoreStateValues(): boolean;
  18200. /** @hidden */
  18201. _initCache(): void;
  18202. /** @hidden */
  18203. _updateCache(ignoreParentClass?: boolean): void;
  18204. /** @hidden */
  18205. _isSynchronizedViewMatrix(): boolean;
  18206. /** @hidden */
  18207. _computeLocalCameraSpeed(): number;
  18208. /**
  18209. * Defines the target the camera should look at.
  18210. * @param target Defines the new target as a Vector or a mesh
  18211. */
  18212. setTarget(target: Vector3): void;
  18213. /**
  18214. * Return the current target position of the camera. This value is expressed in local space.
  18215. * @returns the target position
  18216. */
  18217. getTarget(): Vector3;
  18218. /** @hidden */
  18219. _decideIfNeedsToMove(): boolean;
  18220. /** @hidden */
  18221. _updatePosition(): void;
  18222. /** @hidden */
  18223. _checkInputs(): void;
  18224. protected _updateCameraRotationMatrix(): void;
  18225. /**
  18226. * 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)
  18227. * @returns the current camera
  18228. */
  18229. private _rotateUpVectorWithCameraRotationMatrix;
  18230. private _cachedRotationZ;
  18231. private _cachedQuaternionRotationZ;
  18232. /** @hidden */
  18233. _getViewMatrix(): Matrix;
  18234. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18235. /**
  18236. * @hidden
  18237. */
  18238. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18239. /**
  18240. * @hidden
  18241. */
  18242. _updateRigCameras(): void;
  18243. private _getRigCamPositionAndTarget;
  18244. /**
  18245. * Gets the current object class name.
  18246. * @return the class name
  18247. */
  18248. getClassName(): string;
  18249. }
  18250. }
  18251. declare module BABYLON {
  18252. /**
  18253. * Gather the list of keyboard event types as constants.
  18254. */
  18255. export class KeyboardEventTypes {
  18256. /**
  18257. * The keydown event is fired when a key becomes active (pressed).
  18258. */
  18259. static readonly KEYDOWN: number;
  18260. /**
  18261. * The keyup event is fired when a key has been released.
  18262. */
  18263. static readonly KEYUP: number;
  18264. }
  18265. /**
  18266. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18267. */
  18268. export class KeyboardInfo {
  18269. /**
  18270. * Defines the type of event (KeyboardEventTypes)
  18271. */
  18272. type: number;
  18273. /**
  18274. * Defines the related dom event
  18275. */
  18276. event: KeyboardEvent;
  18277. /**
  18278. * Instantiates a new keyboard info.
  18279. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18280. * @param type Defines the type of event (KeyboardEventTypes)
  18281. * @param event Defines the related dom event
  18282. */
  18283. constructor(
  18284. /**
  18285. * Defines the type of event (KeyboardEventTypes)
  18286. */
  18287. type: number,
  18288. /**
  18289. * Defines the related dom event
  18290. */
  18291. event: KeyboardEvent);
  18292. }
  18293. /**
  18294. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18295. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18296. */
  18297. export class KeyboardInfoPre extends KeyboardInfo {
  18298. /**
  18299. * Defines the type of event (KeyboardEventTypes)
  18300. */
  18301. type: number;
  18302. /**
  18303. * Defines the related dom event
  18304. */
  18305. event: KeyboardEvent;
  18306. /**
  18307. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18308. */
  18309. skipOnPointerObservable: boolean;
  18310. /**
  18311. * Instantiates a new keyboard pre info.
  18312. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18313. * @param type Defines the type of event (KeyboardEventTypes)
  18314. * @param event Defines the related dom event
  18315. */
  18316. constructor(
  18317. /**
  18318. * Defines the type of event (KeyboardEventTypes)
  18319. */
  18320. type: number,
  18321. /**
  18322. * Defines the related dom event
  18323. */
  18324. event: KeyboardEvent);
  18325. }
  18326. }
  18327. declare module BABYLON {
  18328. /**
  18329. * Manage the keyboard inputs to control the movement of a free camera.
  18330. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18331. */
  18332. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18333. /**
  18334. * Defines the camera the input is attached to.
  18335. */
  18336. camera: FreeCamera;
  18337. /**
  18338. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18339. */
  18340. keysUp: number[];
  18341. /**
  18342. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18343. */
  18344. keysUpward: number[];
  18345. /**
  18346. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18347. */
  18348. keysDown: number[];
  18349. /**
  18350. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18351. */
  18352. keysDownward: number[];
  18353. /**
  18354. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18355. */
  18356. keysLeft: number[];
  18357. /**
  18358. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18359. */
  18360. keysRight: number[];
  18361. private _keys;
  18362. private _onCanvasBlurObserver;
  18363. private _onKeyboardObserver;
  18364. private _engine;
  18365. private _scene;
  18366. /**
  18367. * Attach the input controls to a specific dom element to get the input from.
  18368. * @param element Defines the element the controls should be listened from
  18369. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18370. */
  18371. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18372. /**
  18373. * Detach the current controls from the specified dom element.
  18374. * @param element Defines the element to stop listening the inputs from
  18375. */
  18376. detachControl(element: Nullable<HTMLElement>): void;
  18377. /**
  18378. * Update the current camera state depending on the inputs that have been used this frame.
  18379. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18380. */
  18381. checkInputs(): void;
  18382. /**
  18383. * Gets the class name of the current intput.
  18384. * @returns the class name
  18385. */
  18386. getClassName(): string;
  18387. /** @hidden */
  18388. _onLostFocus(): void;
  18389. /**
  18390. * Get the friendly name associated with the input class.
  18391. * @returns the input friendly name
  18392. */
  18393. getSimpleName(): string;
  18394. }
  18395. }
  18396. declare module BABYLON {
  18397. /**
  18398. * Gather the list of pointer event types as constants.
  18399. */
  18400. export class PointerEventTypes {
  18401. /**
  18402. * 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.
  18403. */
  18404. static readonly POINTERDOWN: number;
  18405. /**
  18406. * The pointerup event is fired when a pointer is no longer active.
  18407. */
  18408. static readonly POINTERUP: number;
  18409. /**
  18410. * The pointermove event is fired when a pointer changes coordinates.
  18411. */
  18412. static readonly POINTERMOVE: number;
  18413. /**
  18414. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18415. */
  18416. static readonly POINTERWHEEL: number;
  18417. /**
  18418. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18419. */
  18420. static readonly POINTERPICK: number;
  18421. /**
  18422. * The pointertap event is fired when a the object has been touched and released without drag.
  18423. */
  18424. static readonly POINTERTAP: number;
  18425. /**
  18426. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18427. */
  18428. static readonly POINTERDOUBLETAP: number;
  18429. }
  18430. /**
  18431. * Base class of pointer info types.
  18432. */
  18433. export class PointerInfoBase {
  18434. /**
  18435. * Defines the type of event (PointerEventTypes)
  18436. */
  18437. type: number;
  18438. /**
  18439. * Defines the related dom event
  18440. */
  18441. event: PointerEvent | MouseWheelEvent;
  18442. /**
  18443. * Instantiates the base class of pointers info.
  18444. * @param type Defines the type of event (PointerEventTypes)
  18445. * @param event Defines the related dom event
  18446. */
  18447. constructor(
  18448. /**
  18449. * Defines the type of event (PointerEventTypes)
  18450. */
  18451. type: number,
  18452. /**
  18453. * Defines the related dom event
  18454. */
  18455. event: PointerEvent | MouseWheelEvent);
  18456. }
  18457. /**
  18458. * This class is used to store pointer related info for the onPrePointerObservable event.
  18459. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18460. */
  18461. export class PointerInfoPre extends PointerInfoBase {
  18462. /**
  18463. * Ray from a pointer if availible (eg. 6dof controller)
  18464. */
  18465. ray: Nullable<Ray>;
  18466. /**
  18467. * Defines the local position of the pointer on the canvas.
  18468. */
  18469. localPosition: Vector2;
  18470. /**
  18471. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18472. */
  18473. skipOnPointerObservable: boolean;
  18474. /**
  18475. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18476. * @param type Defines the type of event (PointerEventTypes)
  18477. * @param event Defines the related dom event
  18478. * @param localX Defines the local x coordinates of the pointer when the event occured
  18479. * @param localY Defines the local y coordinates of the pointer when the event occured
  18480. */
  18481. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18482. }
  18483. /**
  18484. * This type contains all the data related to a pointer event in Babylon.js.
  18485. * 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.
  18486. */
  18487. export class PointerInfo extends PointerInfoBase {
  18488. /**
  18489. * Defines the picking info associated to the info (if any)\
  18490. */
  18491. pickInfo: Nullable<PickingInfo>;
  18492. /**
  18493. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18494. * @param type Defines the type of event (PointerEventTypes)
  18495. * @param event Defines the related dom event
  18496. * @param pickInfo Defines the picking info associated to the info (if any)\
  18497. */
  18498. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18499. /**
  18500. * Defines the picking info associated to the info (if any)\
  18501. */
  18502. pickInfo: Nullable<PickingInfo>);
  18503. }
  18504. /**
  18505. * Data relating to a touch event on the screen.
  18506. */
  18507. export interface PointerTouch {
  18508. /**
  18509. * X coordinate of touch.
  18510. */
  18511. x: number;
  18512. /**
  18513. * Y coordinate of touch.
  18514. */
  18515. y: number;
  18516. /**
  18517. * Id of touch. Unique for each finger.
  18518. */
  18519. pointerId: number;
  18520. /**
  18521. * Event type passed from DOM.
  18522. */
  18523. type: any;
  18524. }
  18525. }
  18526. declare module BABYLON {
  18527. /**
  18528. * Manage the mouse inputs to control the movement of a free camera.
  18529. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18530. */
  18531. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18532. /**
  18533. * Define if touch is enabled in the mouse input
  18534. */
  18535. touchEnabled: boolean;
  18536. /**
  18537. * Defines the camera the input is attached to.
  18538. */
  18539. camera: FreeCamera;
  18540. /**
  18541. * Defines the buttons associated with the input to handle camera move.
  18542. */
  18543. buttons: number[];
  18544. /**
  18545. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18546. */
  18547. angularSensibility: number;
  18548. private _pointerInput;
  18549. private _onMouseMove;
  18550. private _observer;
  18551. private previousPosition;
  18552. /**
  18553. * Observable for when a pointer move event occurs containing the move offset
  18554. */
  18555. onPointerMovedObservable: Observable<{
  18556. offsetX: number;
  18557. offsetY: number;
  18558. }>;
  18559. /**
  18560. * @hidden
  18561. * If the camera should be rotated automatically based on pointer movement
  18562. */
  18563. _allowCameraRotation: boolean;
  18564. /**
  18565. * Manage the mouse inputs to control the movement of a free camera.
  18566. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18567. * @param touchEnabled Defines if touch is enabled or not
  18568. */
  18569. constructor(
  18570. /**
  18571. * Define if touch is enabled in the mouse input
  18572. */
  18573. touchEnabled?: boolean);
  18574. /**
  18575. * Attach the input controls to a specific dom element to get the input from.
  18576. * @param element Defines the element the controls should be listened from
  18577. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18578. */
  18579. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18580. /**
  18581. * Called on JS contextmenu event.
  18582. * Override this method to provide functionality.
  18583. */
  18584. protected onContextMenu(evt: PointerEvent): void;
  18585. /**
  18586. * Detach the current controls from the specified dom element.
  18587. * @param element Defines the element to stop listening the inputs from
  18588. */
  18589. detachControl(element: Nullable<HTMLElement>): void;
  18590. /**
  18591. * Gets the class name of the current intput.
  18592. * @returns the class name
  18593. */
  18594. getClassName(): string;
  18595. /**
  18596. * Get the friendly name associated with the input class.
  18597. * @returns the input friendly name
  18598. */
  18599. getSimpleName(): string;
  18600. }
  18601. }
  18602. declare module BABYLON {
  18603. /**
  18604. * Manage the touch inputs to control the movement of a free camera.
  18605. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18606. */
  18607. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18608. /**
  18609. * Defines the camera the input is attached to.
  18610. */
  18611. camera: FreeCamera;
  18612. /**
  18613. * Defines the touch sensibility for rotation.
  18614. * The higher the faster.
  18615. */
  18616. touchAngularSensibility: number;
  18617. /**
  18618. * Defines the touch sensibility for move.
  18619. * The higher the faster.
  18620. */
  18621. touchMoveSensibility: number;
  18622. private _offsetX;
  18623. private _offsetY;
  18624. private _pointerPressed;
  18625. private _pointerInput;
  18626. private _observer;
  18627. private _onLostFocus;
  18628. /**
  18629. * Attach the input controls to a specific dom element to get the input from.
  18630. * @param element Defines the element the controls should be listened from
  18631. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18632. */
  18633. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18634. /**
  18635. * Detach the current controls from the specified dom element.
  18636. * @param element Defines the element to stop listening the inputs from
  18637. */
  18638. detachControl(element: Nullable<HTMLElement>): void;
  18639. /**
  18640. * Update the current camera state depending on the inputs that have been used this frame.
  18641. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18642. */
  18643. checkInputs(): void;
  18644. /**
  18645. * Gets the class name of the current intput.
  18646. * @returns the class name
  18647. */
  18648. getClassName(): string;
  18649. /**
  18650. * Get the friendly name associated with the input class.
  18651. * @returns the input friendly name
  18652. */
  18653. getSimpleName(): string;
  18654. }
  18655. }
  18656. declare module BABYLON {
  18657. /**
  18658. * Default Inputs manager for the FreeCamera.
  18659. * It groups all the default supported inputs for ease of use.
  18660. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18661. */
  18662. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18663. /**
  18664. * @hidden
  18665. */
  18666. _mouseInput: Nullable<FreeCameraMouseInput>;
  18667. /**
  18668. * Instantiates a new FreeCameraInputsManager.
  18669. * @param camera Defines the camera the inputs belong to
  18670. */
  18671. constructor(camera: FreeCamera);
  18672. /**
  18673. * Add keyboard input support to the input manager.
  18674. * @returns the current input manager
  18675. */
  18676. addKeyboard(): FreeCameraInputsManager;
  18677. /**
  18678. * Add mouse input support to the input manager.
  18679. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18680. * @returns the current input manager
  18681. */
  18682. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18683. /**
  18684. * Removes the mouse input support from the manager
  18685. * @returns the current input manager
  18686. */
  18687. removeMouse(): FreeCameraInputsManager;
  18688. /**
  18689. * Add touch input support to the input manager.
  18690. * @returns the current input manager
  18691. */
  18692. addTouch(): FreeCameraInputsManager;
  18693. /**
  18694. * Remove all attached input methods from a camera
  18695. */
  18696. clear(): void;
  18697. }
  18698. }
  18699. declare module BABYLON {
  18700. /**
  18701. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18702. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18703. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18704. */
  18705. export class FreeCamera extends TargetCamera {
  18706. /**
  18707. * Define the collision ellipsoid of the camera.
  18708. * This is helpful to simulate a camera body like the player body around the camera
  18709. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18710. */
  18711. ellipsoid: Vector3;
  18712. /**
  18713. * Define an offset for the position of the ellipsoid around the camera.
  18714. * This can be helpful to determine the center of the body near the gravity center of the body
  18715. * instead of its head.
  18716. */
  18717. ellipsoidOffset: Vector3;
  18718. /**
  18719. * Enable or disable collisions of the camera with the rest of the scene objects.
  18720. */
  18721. checkCollisions: boolean;
  18722. /**
  18723. * Enable or disable gravity on the camera.
  18724. */
  18725. applyGravity: boolean;
  18726. /**
  18727. * Define the input manager associated to the camera.
  18728. */
  18729. inputs: FreeCameraInputsManager;
  18730. /**
  18731. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18732. * Higher values reduce sensitivity.
  18733. */
  18734. get angularSensibility(): number;
  18735. /**
  18736. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18737. * Higher values reduce sensitivity.
  18738. */
  18739. set angularSensibility(value: number);
  18740. /**
  18741. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18742. */
  18743. get keysUp(): number[];
  18744. set keysUp(value: number[]);
  18745. /**
  18746. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18747. */
  18748. get keysUpward(): number[];
  18749. set keysUpward(value: number[]);
  18750. /**
  18751. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18752. */
  18753. get keysDown(): number[];
  18754. set keysDown(value: number[]);
  18755. /**
  18756. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18757. */
  18758. get keysDownward(): number[];
  18759. set keysDownward(value: number[]);
  18760. /**
  18761. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18762. */
  18763. get keysLeft(): number[];
  18764. set keysLeft(value: number[]);
  18765. /**
  18766. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18767. */
  18768. get keysRight(): number[];
  18769. set keysRight(value: number[]);
  18770. /**
  18771. * Event raised when the camera collide with a mesh in the scene.
  18772. */
  18773. onCollide: (collidedMesh: AbstractMesh) => void;
  18774. private _collider;
  18775. private _needMoveForGravity;
  18776. private _oldPosition;
  18777. private _diffPosition;
  18778. private _newPosition;
  18779. /** @hidden */
  18780. _localDirection: Vector3;
  18781. /** @hidden */
  18782. _transformedDirection: Vector3;
  18783. /**
  18784. * Instantiates a Free Camera.
  18785. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18786. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18787. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18788. * @param name Define the name of the camera in the scene
  18789. * @param position Define the start position of the camera in the scene
  18790. * @param scene Define the scene the camera belongs to
  18791. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18792. */
  18793. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18794. /**
  18795. * Attached controls to the current camera.
  18796. * @param element Defines the element the controls should be listened from
  18797. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18798. */
  18799. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18800. /**
  18801. * Detach the current controls from the camera.
  18802. * The camera will stop reacting to inputs.
  18803. * @param element Defines the element to stop listening the inputs from
  18804. */
  18805. detachControl(element: HTMLElement): void;
  18806. private _collisionMask;
  18807. /**
  18808. * Define a collision mask to limit the list of object the camera can collide with
  18809. */
  18810. get collisionMask(): number;
  18811. set collisionMask(mask: number);
  18812. /** @hidden */
  18813. _collideWithWorld(displacement: Vector3): void;
  18814. private _onCollisionPositionChange;
  18815. /** @hidden */
  18816. _checkInputs(): void;
  18817. /** @hidden */
  18818. _decideIfNeedsToMove(): boolean;
  18819. /** @hidden */
  18820. _updatePosition(): void;
  18821. /**
  18822. * Destroy the camera and release the current resources hold by it.
  18823. */
  18824. dispose(): void;
  18825. /**
  18826. * Gets the current object class name.
  18827. * @return the class name
  18828. */
  18829. getClassName(): string;
  18830. }
  18831. }
  18832. declare module BABYLON {
  18833. /**
  18834. * Represents a gamepad control stick position
  18835. */
  18836. export class StickValues {
  18837. /**
  18838. * The x component of the control stick
  18839. */
  18840. x: number;
  18841. /**
  18842. * The y component of the control stick
  18843. */
  18844. y: number;
  18845. /**
  18846. * Initializes the gamepad x and y control stick values
  18847. * @param x The x component of the gamepad control stick value
  18848. * @param y The y component of the gamepad control stick value
  18849. */
  18850. constructor(
  18851. /**
  18852. * The x component of the control stick
  18853. */
  18854. x: number,
  18855. /**
  18856. * The y component of the control stick
  18857. */
  18858. y: number);
  18859. }
  18860. /**
  18861. * An interface which manages callbacks for gamepad button changes
  18862. */
  18863. export interface GamepadButtonChanges {
  18864. /**
  18865. * Called when a gamepad has been changed
  18866. */
  18867. changed: boolean;
  18868. /**
  18869. * Called when a gamepad press event has been triggered
  18870. */
  18871. pressChanged: boolean;
  18872. /**
  18873. * Called when a touch event has been triggered
  18874. */
  18875. touchChanged: boolean;
  18876. /**
  18877. * Called when a value has changed
  18878. */
  18879. valueChanged: boolean;
  18880. }
  18881. /**
  18882. * Represents a gamepad
  18883. */
  18884. export class Gamepad {
  18885. /**
  18886. * The id of the gamepad
  18887. */
  18888. id: string;
  18889. /**
  18890. * The index of the gamepad
  18891. */
  18892. index: number;
  18893. /**
  18894. * The browser gamepad
  18895. */
  18896. browserGamepad: any;
  18897. /**
  18898. * Specifies what type of gamepad this represents
  18899. */
  18900. type: number;
  18901. private _leftStick;
  18902. private _rightStick;
  18903. /** @hidden */
  18904. _isConnected: boolean;
  18905. private _leftStickAxisX;
  18906. private _leftStickAxisY;
  18907. private _rightStickAxisX;
  18908. private _rightStickAxisY;
  18909. /**
  18910. * Triggered when the left control stick has been changed
  18911. */
  18912. private _onleftstickchanged;
  18913. /**
  18914. * Triggered when the right control stick has been changed
  18915. */
  18916. private _onrightstickchanged;
  18917. /**
  18918. * Represents a gamepad controller
  18919. */
  18920. static GAMEPAD: number;
  18921. /**
  18922. * Represents a generic controller
  18923. */
  18924. static GENERIC: number;
  18925. /**
  18926. * Represents an XBox controller
  18927. */
  18928. static XBOX: number;
  18929. /**
  18930. * Represents a pose-enabled controller
  18931. */
  18932. static POSE_ENABLED: number;
  18933. /**
  18934. * Represents an Dual Shock controller
  18935. */
  18936. static DUALSHOCK: number;
  18937. /**
  18938. * Specifies whether the left control stick should be Y-inverted
  18939. */
  18940. protected _invertLeftStickY: boolean;
  18941. /**
  18942. * Specifies if the gamepad has been connected
  18943. */
  18944. get isConnected(): boolean;
  18945. /**
  18946. * Initializes the gamepad
  18947. * @param id The id of the gamepad
  18948. * @param index The index of the gamepad
  18949. * @param browserGamepad The browser gamepad
  18950. * @param leftStickX The x component of the left joystick
  18951. * @param leftStickY The y component of the left joystick
  18952. * @param rightStickX The x component of the right joystick
  18953. * @param rightStickY The y component of the right joystick
  18954. */
  18955. constructor(
  18956. /**
  18957. * The id of the gamepad
  18958. */
  18959. id: string,
  18960. /**
  18961. * The index of the gamepad
  18962. */
  18963. index: number,
  18964. /**
  18965. * The browser gamepad
  18966. */
  18967. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  18968. /**
  18969. * Callback triggered when the left joystick has changed
  18970. * @param callback
  18971. */
  18972. onleftstickchanged(callback: (values: StickValues) => void): void;
  18973. /**
  18974. * Callback triggered when the right joystick has changed
  18975. * @param callback
  18976. */
  18977. onrightstickchanged(callback: (values: StickValues) => void): void;
  18978. /**
  18979. * Gets the left joystick
  18980. */
  18981. get leftStick(): StickValues;
  18982. /**
  18983. * Sets the left joystick values
  18984. */
  18985. set leftStick(newValues: StickValues);
  18986. /**
  18987. * Gets the right joystick
  18988. */
  18989. get rightStick(): StickValues;
  18990. /**
  18991. * Sets the right joystick value
  18992. */
  18993. set rightStick(newValues: StickValues);
  18994. /**
  18995. * Updates the gamepad joystick positions
  18996. */
  18997. update(): void;
  18998. /**
  18999. * Disposes the gamepad
  19000. */
  19001. dispose(): void;
  19002. }
  19003. /**
  19004. * Represents a generic gamepad
  19005. */
  19006. export class GenericPad extends Gamepad {
  19007. private _buttons;
  19008. private _onbuttondown;
  19009. private _onbuttonup;
  19010. /**
  19011. * Observable triggered when a button has been pressed
  19012. */
  19013. onButtonDownObservable: Observable<number>;
  19014. /**
  19015. * Observable triggered when a button has been released
  19016. */
  19017. onButtonUpObservable: Observable<number>;
  19018. /**
  19019. * Callback triggered when a button has been pressed
  19020. * @param callback Called when a button has been pressed
  19021. */
  19022. onbuttondown(callback: (buttonPressed: number) => void): void;
  19023. /**
  19024. * Callback triggered when a button has been released
  19025. * @param callback Called when a button has been released
  19026. */
  19027. onbuttonup(callback: (buttonReleased: number) => void): void;
  19028. /**
  19029. * Initializes the generic gamepad
  19030. * @param id The id of the generic gamepad
  19031. * @param index The index of the generic gamepad
  19032. * @param browserGamepad The browser gamepad
  19033. */
  19034. constructor(id: string, index: number, browserGamepad: any);
  19035. private _setButtonValue;
  19036. /**
  19037. * Updates the generic gamepad
  19038. */
  19039. update(): void;
  19040. /**
  19041. * Disposes the generic gamepad
  19042. */
  19043. dispose(): void;
  19044. }
  19045. }
  19046. declare module BABYLON {
  19047. /**
  19048. * Defines the types of pose enabled controllers that are supported
  19049. */
  19050. export enum PoseEnabledControllerType {
  19051. /**
  19052. * HTC Vive
  19053. */
  19054. VIVE = 0,
  19055. /**
  19056. * Oculus Rift
  19057. */
  19058. OCULUS = 1,
  19059. /**
  19060. * Windows mixed reality
  19061. */
  19062. WINDOWS = 2,
  19063. /**
  19064. * Samsung gear VR
  19065. */
  19066. GEAR_VR = 3,
  19067. /**
  19068. * Google Daydream
  19069. */
  19070. DAYDREAM = 4,
  19071. /**
  19072. * Generic
  19073. */
  19074. GENERIC = 5
  19075. }
  19076. /**
  19077. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19078. */
  19079. export interface MutableGamepadButton {
  19080. /**
  19081. * Value of the button/trigger
  19082. */
  19083. value: number;
  19084. /**
  19085. * If the button/trigger is currently touched
  19086. */
  19087. touched: boolean;
  19088. /**
  19089. * If the button/trigger is currently pressed
  19090. */
  19091. pressed: boolean;
  19092. }
  19093. /**
  19094. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19095. * @hidden
  19096. */
  19097. export interface ExtendedGamepadButton extends GamepadButton {
  19098. /**
  19099. * If the button/trigger is currently pressed
  19100. */
  19101. readonly pressed: boolean;
  19102. /**
  19103. * If the button/trigger is currently touched
  19104. */
  19105. readonly touched: boolean;
  19106. /**
  19107. * Value of the button/trigger
  19108. */
  19109. readonly value: number;
  19110. }
  19111. /** @hidden */
  19112. export interface _GamePadFactory {
  19113. /**
  19114. * Returns whether or not the current gamepad can be created for this type of controller.
  19115. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19116. * @returns true if it can be created, otherwise false
  19117. */
  19118. canCreate(gamepadInfo: any): boolean;
  19119. /**
  19120. * Creates a new instance of the Gamepad.
  19121. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19122. * @returns the new gamepad instance
  19123. */
  19124. create(gamepadInfo: any): Gamepad;
  19125. }
  19126. /**
  19127. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19128. */
  19129. export class PoseEnabledControllerHelper {
  19130. /** @hidden */
  19131. static _ControllerFactories: _GamePadFactory[];
  19132. /** @hidden */
  19133. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19134. /**
  19135. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19136. * @param vrGamepad the gamepad to initialized
  19137. * @returns a vr controller of the type the gamepad identified as
  19138. */
  19139. static InitiateController(vrGamepad: any): Gamepad;
  19140. }
  19141. /**
  19142. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19143. */
  19144. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19145. /**
  19146. * If the controller is used in a webXR session
  19147. */
  19148. isXR: boolean;
  19149. private _deviceRoomPosition;
  19150. private _deviceRoomRotationQuaternion;
  19151. /**
  19152. * The device position in babylon space
  19153. */
  19154. devicePosition: Vector3;
  19155. /**
  19156. * The device rotation in babylon space
  19157. */
  19158. deviceRotationQuaternion: Quaternion;
  19159. /**
  19160. * The scale factor of the device in babylon space
  19161. */
  19162. deviceScaleFactor: number;
  19163. /**
  19164. * (Likely devicePosition should be used instead) The device position in its room space
  19165. */
  19166. position: Vector3;
  19167. /**
  19168. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19169. */
  19170. rotationQuaternion: Quaternion;
  19171. /**
  19172. * The type of controller (Eg. Windows mixed reality)
  19173. */
  19174. controllerType: PoseEnabledControllerType;
  19175. protected _calculatedPosition: Vector3;
  19176. private _calculatedRotation;
  19177. /**
  19178. * The raw pose from the device
  19179. */
  19180. rawPose: DevicePose;
  19181. private _trackPosition;
  19182. private _maxRotationDistFromHeadset;
  19183. private _draggedRoomRotation;
  19184. /**
  19185. * @hidden
  19186. */
  19187. _disableTrackPosition(fixedPosition: Vector3): void;
  19188. /**
  19189. * Internal, the mesh attached to the controller
  19190. * @hidden
  19191. */
  19192. _mesh: Nullable<AbstractMesh>;
  19193. private _poseControlledCamera;
  19194. private _leftHandSystemQuaternion;
  19195. /**
  19196. * Internal, matrix used to convert room space to babylon space
  19197. * @hidden
  19198. */
  19199. _deviceToWorld: Matrix;
  19200. /**
  19201. * Node to be used when casting a ray from the controller
  19202. * @hidden
  19203. */
  19204. _pointingPoseNode: Nullable<TransformNode>;
  19205. /**
  19206. * Name of the child mesh that can be used to cast a ray from the controller
  19207. */
  19208. static readonly POINTING_POSE: string;
  19209. /**
  19210. * Creates a new PoseEnabledController from a gamepad
  19211. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19212. */
  19213. constructor(browserGamepad: any);
  19214. private _workingMatrix;
  19215. /**
  19216. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19217. */
  19218. update(): void;
  19219. /**
  19220. * Updates only the pose device and mesh without doing any button event checking
  19221. */
  19222. protected _updatePoseAndMesh(): void;
  19223. /**
  19224. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19225. * @param poseData raw pose fromthe device
  19226. */
  19227. updateFromDevice(poseData: DevicePose): void;
  19228. /**
  19229. * @hidden
  19230. */
  19231. _meshAttachedObservable: Observable<AbstractMesh>;
  19232. /**
  19233. * Attaches a mesh to the controller
  19234. * @param mesh the mesh to be attached
  19235. */
  19236. attachToMesh(mesh: AbstractMesh): void;
  19237. /**
  19238. * Attaches the controllers mesh to a camera
  19239. * @param camera the camera the mesh should be attached to
  19240. */
  19241. attachToPoseControlledCamera(camera: TargetCamera): void;
  19242. /**
  19243. * Disposes of the controller
  19244. */
  19245. dispose(): void;
  19246. /**
  19247. * The mesh that is attached to the controller
  19248. */
  19249. get mesh(): Nullable<AbstractMesh>;
  19250. /**
  19251. * Gets the ray of the controller in the direction the controller is pointing
  19252. * @param length the length the resulting ray should be
  19253. * @returns a ray in the direction the controller is pointing
  19254. */
  19255. getForwardRay(length?: number): Ray;
  19256. }
  19257. }
  19258. declare module BABYLON {
  19259. /**
  19260. * Defines the WebVRController object that represents controllers tracked in 3D space
  19261. */
  19262. export abstract class WebVRController extends PoseEnabledController {
  19263. /**
  19264. * Internal, the default controller model for the controller
  19265. */
  19266. protected _defaultModel: Nullable<AbstractMesh>;
  19267. /**
  19268. * Fired when the trigger state has changed
  19269. */
  19270. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19271. /**
  19272. * Fired when the main button state has changed
  19273. */
  19274. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19275. /**
  19276. * Fired when the secondary button state has changed
  19277. */
  19278. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19279. /**
  19280. * Fired when the pad state has changed
  19281. */
  19282. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19283. /**
  19284. * Fired when controllers stick values have changed
  19285. */
  19286. onPadValuesChangedObservable: Observable<StickValues>;
  19287. /**
  19288. * Array of button availible on the controller
  19289. */
  19290. protected _buttons: Array<MutableGamepadButton>;
  19291. private _onButtonStateChange;
  19292. /**
  19293. * Fired when a controller button's state has changed
  19294. * @param callback the callback containing the button that was modified
  19295. */
  19296. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19297. /**
  19298. * X and Y axis corresponding to the controllers joystick
  19299. */
  19300. pad: StickValues;
  19301. /**
  19302. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19303. */
  19304. hand: string;
  19305. /**
  19306. * The default controller model for the controller
  19307. */
  19308. get defaultModel(): Nullable<AbstractMesh>;
  19309. /**
  19310. * Creates a new WebVRController from a gamepad
  19311. * @param vrGamepad the gamepad that the WebVRController should be created from
  19312. */
  19313. constructor(vrGamepad: any);
  19314. /**
  19315. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19316. */
  19317. update(): void;
  19318. /**
  19319. * Function to be called when a button is modified
  19320. */
  19321. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19322. /**
  19323. * Loads a mesh and attaches it to the controller
  19324. * @param scene the scene the mesh should be added to
  19325. * @param meshLoaded callback for when the mesh has been loaded
  19326. */
  19327. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19328. private _setButtonValue;
  19329. private _changes;
  19330. private _checkChanges;
  19331. /**
  19332. * Disposes of th webVRCOntroller
  19333. */
  19334. dispose(): void;
  19335. }
  19336. }
  19337. declare module BABYLON {
  19338. /**
  19339. * The HemisphericLight simulates the ambient environment light,
  19340. * so the passed direction is the light reflection direction, not the incoming direction.
  19341. */
  19342. export class HemisphericLight extends Light {
  19343. /**
  19344. * The groundColor is the light in the opposite direction to the one specified during creation.
  19345. * 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.
  19346. */
  19347. groundColor: Color3;
  19348. /**
  19349. * The light reflection direction, not the incoming direction.
  19350. */
  19351. direction: Vector3;
  19352. /**
  19353. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19354. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19355. * The HemisphericLight can't cast shadows.
  19356. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19357. * @param name The friendly name of the light
  19358. * @param direction The direction of the light reflection
  19359. * @param scene The scene the light belongs to
  19360. */
  19361. constructor(name: string, direction: Vector3, scene: Scene);
  19362. protected _buildUniformLayout(): void;
  19363. /**
  19364. * Returns the string "HemisphericLight".
  19365. * @return The class name
  19366. */
  19367. getClassName(): string;
  19368. /**
  19369. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19370. * Returns the updated direction.
  19371. * @param target The target the direction should point to
  19372. * @return The computed direction
  19373. */
  19374. setDirectionToTarget(target: Vector3): Vector3;
  19375. /**
  19376. * Returns the shadow generator associated to the light.
  19377. * @returns Always null for hemispheric lights because it does not support shadows.
  19378. */
  19379. getShadowGenerator(): Nullable<IShadowGenerator>;
  19380. /**
  19381. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19382. * @param effect The effect to update
  19383. * @param lightIndex The index of the light in the effect to update
  19384. * @returns The hemispheric light
  19385. */
  19386. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19387. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19388. /**
  19389. * Computes the world matrix of the node
  19390. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19391. * @param useWasUpdatedFlag defines a reserved property
  19392. * @returns the world matrix
  19393. */
  19394. computeWorldMatrix(): Matrix;
  19395. /**
  19396. * Returns the integer 3.
  19397. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19398. */
  19399. getTypeID(): number;
  19400. /**
  19401. * Prepares the list of defines specific to the light type.
  19402. * @param defines the list of defines
  19403. * @param lightIndex defines the index of the light for the effect
  19404. */
  19405. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19406. }
  19407. }
  19408. declare module BABYLON {
  19409. /** @hidden */
  19410. export var vrMultiviewToSingleviewPixelShader: {
  19411. name: string;
  19412. shader: string;
  19413. };
  19414. }
  19415. declare module BABYLON {
  19416. /**
  19417. * Renders to multiple views with a single draw call
  19418. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19419. */
  19420. export class MultiviewRenderTarget extends RenderTargetTexture {
  19421. /**
  19422. * Creates a multiview render target
  19423. * @param scene scene used with the render target
  19424. * @param size the size of the render target (used for each view)
  19425. */
  19426. constructor(scene: Scene, size?: number | {
  19427. width: number;
  19428. height: number;
  19429. } | {
  19430. ratio: number;
  19431. });
  19432. /**
  19433. * @hidden
  19434. * @param faceIndex the face index, if its a cube texture
  19435. */
  19436. _bindFrameBuffer(faceIndex?: number): void;
  19437. /**
  19438. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19439. * @returns the view count
  19440. */
  19441. getViewCount(): number;
  19442. }
  19443. }
  19444. declare module BABYLON {
  19445. interface Engine {
  19446. /**
  19447. * Creates a new multiview render target
  19448. * @param width defines the width of the texture
  19449. * @param height defines the height of the texture
  19450. * @returns the created multiview texture
  19451. */
  19452. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19453. /**
  19454. * Binds a multiview framebuffer to be drawn to
  19455. * @param multiviewTexture texture to bind
  19456. */
  19457. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19458. }
  19459. interface Camera {
  19460. /**
  19461. * @hidden
  19462. * 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)
  19463. */
  19464. _useMultiviewToSingleView: boolean;
  19465. /**
  19466. * @hidden
  19467. * 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)
  19468. */
  19469. _multiviewTexture: Nullable<RenderTargetTexture>;
  19470. /**
  19471. * @hidden
  19472. * ensures the multiview texture of the camera exists and has the specified width/height
  19473. * @param width height to set on the multiview texture
  19474. * @param height width to set on the multiview texture
  19475. */
  19476. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19477. }
  19478. interface Scene {
  19479. /** @hidden */
  19480. _transformMatrixR: Matrix;
  19481. /** @hidden */
  19482. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19483. /** @hidden */
  19484. _createMultiviewUbo(): void;
  19485. /** @hidden */
  19486. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19487. /** @hidden */
  19488. _renderMultiviewToSingleView(camera: Camera): void;
  19489. }
  19490. }
  19491. declare module BABYLON {
  19492. /**
  19493. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19494. * This will not be used for webXR as it supports displaying texture arrays directly
  19495. */
  19496. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19497. /**
  19498. * Initializes a VRMultiviewToSingleview
  19499. * @param name name of the post process
  19500. * @param camera camera to be applied to
  19501. * @param scaleFactor scaling factor to the size of the output texture
  19502. */
  19503. constructor(name: string, camera: Camera, scaleFactor: number);
  19504. }
  19505. }
  19506. declare module BABYLON {
  19507. /**
  19508. * Interface used to define additional presentation attributes
  19509. */
  19510. export interface IVRPresentationAttributes {
  19511. /**
  19512. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19513. */
  19514. highRefreshRate: boolean;
  19515. /**
  19516. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19517. */
  19518. foveationLevel: number;
  19519. }
  19520. interface Engine {
  19521. /** @hidden */
  19522. _vrDisplay: any;
  19523. /** @hidden */
  19524. _vrSupported: boolean;
  19525. /** @hidden */
  19526. _oldSize: Size;
  19527. /** @hidden */
  19528. _oldHardwareScaleFactor: number;
  19529. /** @hidden */
  19530. _vrExclusivePointerMode: boolean;
  19531. /** @hidden */
  19532. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19533. /** @hidden */
  19534. _onVRDisplayPointerRestricted: () => void;
  19535. /** @hidden */
  19536. _onVRDisplayPointerUnrestricted: () => void;
  19537. /** @hidden */
  19538. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19539. /** @hidden */
  19540. _onVrDisplayDisconnect: Nullable<() => void>;
  19541. /** @hidden */
  19542. _onVrDisplayPresentChange: Nullable<() => void>;
  19543. /**
  19544. * Observable signaled when VR display mode changes
  19545. */
  19546. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19547. /**
  19548. * Observable signaled when VR request present is complete
  19549. */
  19550. onVRRequestPresentComplete: Observable<boolean>;
  19551. /**
  19552. * Observable signaled when VR request present starts
  19553. */
  19554. onVRRequestPresentStart: Observable<Engine>;
  19555. /**
  19556. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19557. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19558. */
  19559. isInVRExclusivePointerMode: boolean;
  19560. /**
  19561. * Gets a boolean indicating if a webVR device was detected
  19562. * @returns true if a webVR device was detected
  19563. */
  19564. isVRDevicePresent(): boolean;
  19565. /**
  19566. * Gets the current webVR device
  19567. * @returns the current webVR device (or null)
  19568. */
  19569. getVRDevice(): any;
  19570. /**
  19571. * Initializes a webVR display and starts listening to display change events
  19572. * The onVRDisplayChangedObservable will be notified upon these changes
  19573. * @returns A promise containing a VRDisplay and if vr is supported
  19574. */
  19575. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19576. /** @hidden */
  19577. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19578. /**
  19579. * Gets or sets the presentation attributes used to configure VR rendering
  19580. */
  19581. vrPresentationAttributes?: IVRPresentationAttributes;
  19582. /**
  19583. * Call this function to switch to webVR mode
  19584. * Will do nothing if webVR is not supported or if there is no webVR device
  19585. * @param options the webvr options provided to the camera. mainly used for multiview
  19586. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19587. */
  19588. enableVR(options: WebVROptions): void;
  19589. /** @hidden */
  19590. _onVRFullScreenTriggered(): void;
  19591. }
  19592. }
  19593. declare module BABYLON {
  19594. /**
  19595. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19596. * IMPORTANT!! The data is right-hand data.
  19597. * @export
  19598. * @interface DevicePose
  19599. */
  19600. export interface DevicePose {
  19601. /**
  19602. * The position of the device, values in array are [x,y,z].
  19603. */
  19604. readonly position: Nullable<Float32Array>;
  19605. /**
  19606. * The linearVelocity of the device, values in array are [x,y,z].
  19607. */
  19608. readonly linearVelocity: Nullable<Float32Array>;
  19609. /**
  19610. * The linearAcceleration of the device, values in array are [x,y,z].
  19611. */
  19612. readonly linearAcceleration: Nullable<Float32Array>;
  19613. /**
  19614. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19615. */
  19616. readonly orientation: Nullable<Float32Array>;
  19617. /**
  19618. * The angularVelocity of the device, values in array are [x,y,z].
  19619. */
  19620. readonly angularVelocity: Nullable<Float32Array>;
  19621. /**
  19622. * The angularAcceleration of the device, values in array are [x,y,z].
  19623. */
  19624. readonly angularAcceleration: Nullable<Float32Array>;
  19625. }
  19626. /**
  19627. * Interface representing a pose controlled object in Babylon.
  19628. * A pose controlled object has both regular pose values as well as pose values
  19629. * from an external device such as a VR head mounted display
  19630. */
  19631. export interface PoseControlled {
  19632. /**
  19633. * The position of the object in babylon space.
  19634. */
  19635. position: Vector3;
  19636. /**
  19637. * The rotation quaternion of the object in babylon space.
  19638. */
  19639. rotationQuaternion: Quaternion;
  19640. /**
  19641. * The position of the device in babylon space.
  19642. */
  19643. devicePosition?: Vector3;
  19644. /**
  19645. * The rotation quaternion of the device in babylon space.
  19646. */
  19647. deviceRotationQuaternion: Quaternion;
  19648. /**
  19649. * The raw pose coming from the device.
  19650. */
  19651. rawPose: Nullable<DevicePose>;
  19652. /**
  19653. * The scale of the device to be used when translating from device space to babylon space.
  19654. */
  19655. deviceScaleFactor: number;
  19656. /**
  19657. * Updates the poseControlled values based on the input device pose.
  19658. * @param poseData the pose data to update the object with
  19659. */
  19660. updateFromDevice(poseData: DevicePose): void;
  19661. }
  19662. /**
  19663. * Set of options to customize the webVRCamera
  19664. */
  19665. export interface WebVROptions {
  19666. /**
  19667. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19668. */
  19669. trackPosition?: boolean;
  19670. /**
  19671. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19672. */
  19673. positionScale?: number;
  19674. /**
  19675. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19676. */
  19677. displayName?: string;
  19678. /**
  19679. * Should the native controller meshes be initialized. (default: true)
  19680. */
  19681. controllerMeshes?: boolean;
  19682. /**
  19683. * Creating a default HemiLight only on controllers. (default: true)
  19684. */
  19685. defaultLightingOnControllers?: boolean;
  19686. /**
  19687. * If you don't want to use the default VR button of the helper. (default: false)
  19688. */
  19689. useCustomVRButton?: boolean;
  19690. /**
  19691. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19692. */
  19693. customVRButton?: HTMLButtonElement;
  19694. /**
  19695. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19696. */
  19697. rayLength?: number;
  19698. /**
  19699. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19700. */
  19701. defaultHeight?: number;
  19702. /**
  19703. * If multiview should be used if availible (default: false)
  19704. */
  19705. useMultiview?: boolean;
  19706. }
  19707. /**
  19708. * This represents a WebVR camera.
  19709. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19710. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19711. */
  19712. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19713. private webVROptions;
  19714. /**
  19715. * @hidden
  19716. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19717. */
  19718. _vrDevice: any;
  19719. /**
  19720. * The rawPose of the vrDevice.
  19721. */
  19722. rawPose: Nullable<DevicePose>;
  19723. private _onVREnabled;
  19724. private _specsVersion;
  19725. private _attached;
  19726. private _frameData;
  19727. protected _descendants: Array<Node>;
  19728. private _deviceRoomPosition;
  19729. /** @hidden */
  19730. _deviceRoomRotationQuaternion: Quaternion;
  19731. private _standingMatrix;
  19732. /**
  19733. * Represents device position in babylon space.
  19734. */
  19735. devicePosition: Vector3;
  19736. /**
  19737. * Represents device rotation in babylon space.
  19738. */
  19739. deviceRotationQuaternion: Quaternion;
  19740. /**
  19741. * The scale of the device to be used when translating from device space to babylon space.
  19742. */
  19743. deviceScaleFactor: number;
  19744. private _deviceToWorld;
  19745. private _worldToDevice;
  19746. /**
  19747. * References to the webVR controllers for the vrDevice.
  19748. */
  19749. controllers: Array<WebVRController>;
  19750. /**
  19751. * Emits an event when a controller is attached.
  19752. */
  19753. onControllersAttachedObservable: Observable<WebVRController[]>;
  19754. /**
  19755. * Emits an event when a controller's mesh has been loaded;
  19756. */
  19757. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19758. /**
  19759. * Emits an event when the HMD's pose has been updated.
  19760. */
  19761. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19762. private _poseSet;
  19763. /**
  19764. * If the rig cameras be used as parent instead of this camera.
  19765. */
  19766. rigParenting: boolean;
  19767. private _lightOnControllers;
  19768. private _defaultHeight?;
  19769. /**
  19770. * Instantiates a WebVRFreeCamera.
  19771. * @param name The name of the WebVRFreeCamera
  19772. * @param position The starting anchor position for the camera
  19773. * @param scene The scene the camera belongs to
  19774. * @param webVROptions a set of customizable options for the webVRCamera
  19775. */
  19776. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19777. /**
  19778. * Gets the device distance from the ground in meters.
  19779. * @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.
  19780. */
  19781. deviceDistanceToRoomGround(): number;
  19782. /**
  19783. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19784. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19785. */
  19786. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19787. /**
  19788. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19789. * @returns A promise with a boolean set to if the standing matrix is supported.
  19790. */
  19791. useStandingMatrixAsync(): Promise<boolean>;
  19792. /**
  19793. * Disposes the camera
  19794. */
  19795. dispose(): void;
  19796. /**
  19797. * Gets a vrController by name.
  19798. * @param name The name of the controller to retreive
  19799. * @returns the controller matching the name specified or null if not found
  19800. */
  19801. getControllerByName(name: string): Nullable<WebVRController>;
  19802. private _leftController;
  19803. /**
  19804. * The controller corresponding to the users left hand.
  19805. */
  19806. get leftController(): Nullable<WebVRController>;
  19807. private _rightController;
  19808. /**
  19809. * The controller corresponding to the users right hand.
  19810. */
  19811. get rightController(): Nullable<WebVRController>;
  19812. /**
  19813. * Casts a ray forward from the vrCamera's gaze.
  19814. * @param length Length of the ray (default: 100)
  19815. * @returns the ray corresponding to the gaze
  19816. */
  19817. getForwardRay(length?: number): Ray;
  19818. /**
  19819. * @hidden
  19820. * Updates the camera based on device's frame data
  19821. */
  19822. _checkInputs(): void;
  19823. /**
  19824. * Updates the poseControlled values based on the input device pose.
  19825. * @param poseData Pose coming from the device
  19826. */
  19827. updateFromDevice(poseData: DevicePose): void;
  19828. private _htmlElementAttached;
  19829. private _detachIfAttached;
  19830. /**
  19831. * WebVR's attach control will start broadcasting frames to the device.
  19832. * Note that in certain browsers (chrome for example) this function must be called
  19833. * within a user-interaction callback. Example:
  19834. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19835. *
  19836. * @param element html element to attach the vrDevice to
  19837. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19838. */
  19839. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19840. /**
  19841. * Detaches the camera from the html element and disables VR
  19842. *
  19843. * @param element html element to detach from
  19844. */
  19845. detachControl(element: HTMLElement): void;
  19846. /**
  19847. * @returns the name of this class
  19848. */
  19849. getClassName(): string;
  19850. /**
  19851. * Calls resetPose on the vrDisplay
  19852. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19853. */
  19854. resetToCurrentRotation(): void;
  19855. /**
  19856. * @hidden
  19857. * Updates the rig cameras (left and right eye)
  19858. */
  19859. _updateRigCameras(): void;
  19860. private _workingVector;
  19861. private _oneVector;
  19862. private _workingMatrix;
  19863. private updateCacheCalled;
  19864. private _correctPositionIfNotTrackPosition;
  19865. /**
  19866. * @hidden
  19867. * Updates the cached values of the camera
  19868. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19869. */
  19870. _updateCache(ignoreParentClass?: boolean): void;
  19871. /**
  19872. * @hidden
  19873. * Get current device position in babylon world
  19874. */
  19875. _computeDevicePosition(): void;
  19876. /**
  19877. * Updates the current device position and rotation in the babylon world
  19878. */
  19879. update(): void;
  19880. /**
  19881. * @hidden
  19882. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19883. * @returns an identity matrix
  19884. */
  19885. _getViewMatrix(): Matrix;
  19886. private _tmpMatrix;
  19887. /**
  19888. * This function is called by the two RIG cameras.
  19889. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19890. * @hidden
  19891. */
  19892. _getWebVRViewMatrix(): Matrix;
  19893. /** @hidden */
  19894. _getWebVRProjectionMatrix(): Matrix;
  19895. private _onGamepadConnectedObserver;
  19896. private _onGamepadDisconnectedObserver;
  19897. private _updateCacheWhenTrackingDisabledObserver;
  19898. /**
  19899. * Initializes the controllers and their meshes
  19900. */
  19901. initControllers(): void;
  19902. }
  19903. }
  19904. declare module BABYLON {
  19905. /**
  19906. * "Static Class" containing the most commonly used helper while dealing with material for
  19907. * rendering purpose.
  19908. *
  19909. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  19910. *
  19911. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  19912. */
  19913. export class MaterialHelper {
  19914. /**
  19915. * Bind the current view position to an effect.
  19916. * @param effect The effect to be bound
  19917. * @param scene The scene the eyes position is used from
  19918. * @param variableName name of the shader variable that will hold the eye position
  19919. */
  19920. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  19921. /**
  19922. * Helps preparing the defines values about the UVs in used in the effect.
  19923. * UVs are shared as much as we can accross channels in the shaders.
  19924. * @param texture The texture we are preparing the UVs for
  19925. * @param defines The defines to update
  19926. * @param key The channel key "diffuse", "specular"... used in the shader
  19927. */
  19928. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  19929. /**
  19930. * Binds a texture matrix value to its corrsponding uniform
  19931. * @param texture The texture to bind the matrix for
  19932. * @param uniformBuffer The uniform buffer receivin the data
  19933. * @param key The channel key "diffuse", "specular"... used in the shader
  19934. */
  19935. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  19936. /**
  19937. * Gets the current status of the fog (should it be enabled?)
  19938. * @param mesh defines the mesh to evaluate for fog support
  19939. * @param scene defines the hosting scene
  19940. * @returns true if fog must be enabled
  19941. */
  19942. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  19943. /**
  19944. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  19945. * @param mesh defines the current mesh
  19946. * @param scene defines the current scene
  19947. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  19948. * @param pointsCloud defines if point cloud rendering has to be turned on
  19949. * @param fogEnabled defines if fog has to be turned on
  19950. * @param alphaTest defines if alpha testing has to be turned on
  19951. * @param defines defines the current list of defines
  19952. */
  19953. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  19954. /**
  19955. * Helper used to prepare the list of defines associated with frame values for shader compilation
  19956. * @param scene defines the current scene
  19957. * @param engine defines the current engine
  19958. * @param defines specifies the list of active defines
  19959. * @param useInstances defines if instances have to be turned on
  19960. * @param useClipPlane defines if clip plane have to be turned on
  19961. */
  19962. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  19963. /**
  19964. * Prepares the defines for bones
  19965. * @param mesh The mesh containing the geometry data we will draw
  19966. * @param defines The defines to update
  19967. */
  19968. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  19969. /**
  19970. * Prepares the defines for morph targets
  19971. * @param mesh The mesh containing the geometry data we will draw
  19972. * @param defines The defines to update
  19973. */
  19974. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  19975. /**
  19976. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  19977. * @param mesh The mesh containing the geometry data we will draw
  19978. * @param defines The defines to update
  19979. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  19980. * @param useBones Precise whether bones should be used or not (override mesh info)
  19981. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  19982. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  19983. * @returns false if defines are considered not dirty and have not been checked
  19984. */
  19985. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  19986. /**
  19987. * Prepares the defines related to multiview
  19988. * @param scene The scene we are intending to draw
  19989. * @param defines The defines to update
  19990. */
  19991. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  19992. /**
  19993. * Prepares the defines related to the light information passed in parameter
  19994. * @param scene The scene we are intending to draw
  19995. * @param mesh The mesh the effect is compiling for
  19996. * @param light The light the effect is compiling for
  19997. * @param lightIndex The index of the light
  19998. * @param defines The defines to update
  19999. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20000. * @param state Defines the current state regarding what is needed (normals, etc...)
  20001. */
  20002. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20003. needNormals: boolean;
  20004. needRebuild: boolean;
  20005. shadowEnabled: boolean;
  20006. specularEnabled: boolean;
  20007. lightmapMode: boolean;
  20008. }): void;
  20009. /**
  20010. * Prepares the defines related to the light information passed in parameter
  20011. * @param scene The scene we are intending to draw
  20012. * @param mesh The mesh the effect is compiling for
  20013. * @param defines The defines to update
  20014. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20015. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20016. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20017. * @returns true if normals will be required for the rest of the effect
  20018. */
  20019. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20020. /**
  20021. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20022. * @param lightIndex defines the light index
  20023. * @param uniformsList The uniform list
  20024. * @param samplersList The sampler list
  20025. * @param projectedLightTexture defines if projected texture must be used
  20026. * @param uniformBuffersList defines an optional list of uniform buffers
  20027. */
  20028. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20029. /**
  20030. * Prepares the uniforms and samplers list to be used in the effect
  20031. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20032. * @param samplersList The sampler list
  20033. * @param defines The defines helping in the list generation
  20034. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20035. */
  20036. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20037. /**
  20038. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20039. * @param defines The defines to update while falling back
  20040. * @param fallbacks The authorized effect fallbacks
  20041. * @param maxSimultaneousLights The maximum number of lights allowed
  20042. * @param rank the current rank of the Effect
  20043. * @returns The newly affected rank
  20044. */
  20045. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20046. private static _TmpMorphInfluencers;
  20047. /**
  20048. * Prepares the list of attributes required for morph targets according to the effect defines.
  20049. * @param attribs The current list of supported attribs
  20050. * @param mesh The mesh to prepare the morph targets attributes for
  20051. * @param influencers The number of influencers
  20052. */
  20053. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20054. /**
  20055. * Prepares the list of attributes required for morph targets according to the effect defines.
  20056. * @param attribs The current list of supported attribs
  20057. * @param mesh The mesh to prepare the morph targets attributes for
  20058. * @param defines The current Defines of the effect
  20059. */
  20060. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20061. /**
  20062. * Prepares the list of attributes required for bones according to the effect defines.
  20063. * @param attribs The current list of supported attribs
  20064. * @param mesh The mesh to prepare the bones attributes for
  20065. * @param defines The current Defines of the effect
  20066. * @param fallbacks The current efffect fallback strategy
  20067. */
  20068. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20069. /**
  20070. * Check and prepare the list of attributes required for instances according to the effect defines.
  20071. * @param attribs The current list of supported attribs
  20072. * @param defines The current MaterialDefines of the effect
  20073. */
  20074. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20075. /**
  20076. * Add the list of attributes required for instances to the attribs array.
  20077. * @param attribs The current list of supported attribs
  20078. */
  20079. static PushAttributesForInstances(attribs: string[]): void;
  20080. /**
  20081. * Binds the light information to the effect.
  20082. * @param light The light containing the generator
  20083. * @param effect The effect we are binding the data to
  20084. * @param lightIndex The light index in the effect used to render
  20085. */
  20086. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20087. /**
  20088. * Binds the lights information from the scene to the effect for the given mesh.
  20089. * @param light Light to bind
  20090. * @param lightIndex Light index
  20091. * @param scene The scene where the light belongs to
  20092. * @param effect The effect we are binding the data to
  20093. * @param useSpecular Defines if specular is supported
  20094. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20095. */
  20096. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20097. /**
  20098. * Binds the lights information from the scene to the effect for the given mesh.
  20099. * @param scene The scene the lights belongs to
  20100. * @param mesh The mesh we are binding the information to render
  20101. * @param effect The effect we are binding the data to
  20102. * @param defines The generated defines for the effect
  20103. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20104. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20105. */
  20106. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20107. private static _tempFogColor;
  20108. /**
  20109. * Binds the fog information from the scene to the effect for the given mesh.
  20110. * @param scene The scene the lights belongs to
  20111. * @param mesh The mesh we are binding the information to render
  20112. * @param effect The effect we are binding the data to
  20113. * @param linearSpace Defines if the fog effect is applied in linear space
  20114. */
  20115. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20116. /**
  20117. * Binds the bones information from the mesh to the effect.
  20118. * @param mesh The mesh we are binding the information to render
  20119. * @param effect The effect we are binding the data to
  20120. */
  20121. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20122. /**
  20123. * Binds the morph targets information from the mesh to the effect.
  20124. * @param abstractMesh The mesh we are binding the information to render
  20125. * @param effect The effect we are binding the data to
  20126. */
  20127. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20128. /**
  20129. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20130. * @param defines The generated defines used in the effect
  20131. * @param effect The effect we are binding the data to
  20132. * @param scene The scene we are willing to render with logarithmic scale for
  20133. */
  20134. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20135. /**
  20136. * Binds the clip plane information from the scene to the effect.
  20137. * @param scene The scene the clip plane information are extracted from
  20138. * @param effect The effect we are binding the data to
  20139. */
  20140. static BindClipPlane(effect: Effect, scene: Scene): void;
  20141. }
  20142. }
  20143. declare module BABYLON {
  20144. /**
  20145. * Block used to expose an input value
  20146. */
  20147. export class InputBlock extends NodeMaterialBlock {
  20148. private _mode;
  20149. private _associatedVariableName;
  20150. private _storedValue;
  20151. private _valueCallback;
  20152. private _type;
  20153. private _animationType;
  20154. /** Gets or set a value used to limit the range of float values */
  20155. min: number;
  20156. /** Gets or set a value used to limit the range of float values */
  20157. max: number;
  20158. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20159. isBoolean: boolean;
  20160. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20161. matrixMode: number;
  20162. /** @hidden */
  20163. _systemValue: Nullable<NodeMaterialSystemValues>;
  20164. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20165. visibleInInspector: boolean;
  20166. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20167. isConstant: boolean;
  20168. /** Gets or sets the group to use to display this block in the Inspector */
  20169. groupInInspector: string;
  20170. /** Gets an observable raised when the value is changed */
  20171. onValueChangedObservable: Observable<InputBlock>;
  20172. /**
  20173. * Gets or sets the connection point type (default is float)
  20174. */
  20175. get type(): NodeMaterialBlockConnectionPointTypes;
  20176. /**
  20177. * Creates a new InputBlock
  20178. * @param name defines the block name
  20179. * @param target defines the target of that block (Vertex by default)
  20180. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20181. */
  20182. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20183. /**
  20184. * Gets the output component
  20185. */
  20186. get output(): NodeMaterialConnectionPoint;
  20187. /**
  20188. * Set the source of this connection point to a vertex attribute
  20189. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20190. * @returns the current connection point
  20191. */
  20192. setAsAttribute(attributeName?: string): InputBlock;
  20193. /**
  20194. * Set the source of this connection point to a system value
  20195. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20196. * @returns the current connection point
  20197. */
  20198. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20199. /**
  20200. * Gets or sets the value of that point.
  20201. * Please note that this value will be ignored if valueCallback is defined
  20202. */
  20203. get value(): any;
  20204. set value(value: any);
  20205. /**
  20206. * Gets or sets a callback used to get the value of that point.
  20207. * Please note that setting this value will force the connection point to ignore the value property
  20208. */
  20209. get valueCallback(): () => any;
  20210. set valueCallback(value: () => any);
  20211. /**
  20212. * Gets or sets the associated variable name in the shader
  20213. */
  20214. get associatedVariableName(): string;
  20215. set associatedVariableName(value: string);
  20216. /** Gets or sets the type of animation applied to the input */
  20217. get animationType(): AnimatedInputBlockTypes;
  20218. set animationType(value: AnimatedInputBlockTypes);
  20219. /**
  20220. * Gets a boolean indicating that this connection point not defined yet
  20221. */
  20222. get isUndefined(): boolean;
  20223. /**
  20224. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20225. * In this case the connection point name must be the name of the uniform to use.
  20226. * Can only be set on inputs
  20227. */
  20228. get isUniform(): boolean;
  20229. set isUniform(value: boolean);
  20230. /**
  20231. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20232. * In this case the connection point name must be the name of the attribute to use
  20233. * Can only be set on inputs
  20234. */
  20235. get isAttribute(): boolean;
  20236. set isAttribute(value: boolean);
  20237. /**
  20238. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20239. * Can only be set on exit points
  20240. */
  20241. get isVarying(): boolean;
  20242. set isVarying(value: boolean);
  20243. /**
  20244. * Gets a boolean indicating that the current connection point is a system value
  20245. */
  20246. get isSystemValue(): boolean;
  20247. /**
  20248. * Gets or sets the current well known value or null if not defined as a system value
  20249. */
  20250. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20251. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20252. /**
  20253. * Gets the current class name
  20254. * @returns the class name
  20255. */
  20256. getClassName(): string;
  20257. /**
  20258. * Animate the input if animationType !== None
  20259. * @param scene defines the rendering scene
  20260. */
  20261. animate(scene: Scene): void;
  20262. private _emitDefine;
  20263. initialize(state: NodeMaterialBuildState): void;
  20264. /**
  20265. * Set the input block to its default value (based on its type)
  20266. */
  20267. setDefaultValue(): void;
  20268. private _emitConstant;
  20269. /** @hidden */
  20270. get _noContextSwitch(): boolean;
  20271. private _emit;
  20272. /** @hidden */
  20273. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20274. /** @hidden */
  20275. _transmit(effect: Effect, scene: Scene): void;
  20276. protected _buildBlock(state: NodeMaterialBuildState): void;
  20277. protected _dumpPropertiesCode(): string;
  20278. dispose(): void;
  20279. serialize(): any;
  20280. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20281. }
  20282. }
  20283. declare module BABYLON {
  20284. /**
  20285. * Enum used to define the compatibility state between two connection points
  20286. */
  20287. export enum NodeMaterialConnectionPointCompatibilityStates {
  20288. /** Points are compatibles */
  20289. Compatible = 0,
  20290. /** Points are incompatible because of their types */
  20291. TypeIncompatible = 1,
  20292. /** Points are incompatible because of their targets (vertex vs fragment) */
  20293. TargetIncompatible = 2
  20294. }
  20295. /**
  20296. * Defines the direction of a connection point
  20297. */
  20298. export enum NodeMaterialConnectionPointDirection {
  20299. /** Input */
  20300. Input = 0,
  20301. /** Output */
  20302. Output = 1
  20303. }
  20304. /**
  20305. * Defines a connection point for a block
  20306. */
  20307. export class NodeMaterialConnectionPoint {
  20308. /** @hidden */
  20309. _ownerBlock: NodeMaterialBlock;
  20310. /** @hidden */
  20311. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20312. private _endpoints;
  20313. private _associatedVariableName;
  20314. private _direction;
  20315. /** @hidden */
  20316. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20317. /** @hidden */
  20318. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20319. private _type;
  20320. /** @hidden */
  20321. _enforceAssociatedVariableName: boolean;
  20322. /** Gets the direction of the point */
  20323. get direction(): NodeMaterialConnectionPointDirection;
  20324. /** Indicates that this connection point needs dual validation before being connected to another point */
  20325. needDualDirectionValidation: boolean;
  20326. /**
  20327. * Gets or sets the additional types supported by this connection point
  20328. */
  20329. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20330. /**
  20331. * Gets or sets the additional types excluded by this connection point
  20332. */
  20333. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20334. /**
  20335. * Observable triggered when this point is connected
  20336. */
  20337. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20338. /**
  20339. * Gets or sets the associated variable name in the shader
  20340. */
  20341. get associatedVariableName(): string;
  20342. set associatedVariableName(value: string);
  20343. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20344. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20345. /**
  20346. * Gets or sets the connection point type (default is float)
  20347. */
  20348. get type(): NodeMaterialBlockConnectionPointTypes;
  20349. set type(value: NodeMaterialBlockConnectionPointTypes);
  20350. /**
  20351. * Gets or sets the connection point name
  20352. */
  20353. name: string;
  20354. /**
  20355. * Gets or sets the connection point name
  20356. */
  20357. displayName: string;
  20358. /**
  20359. * Gets or sets a boolean indicating that this connection point can be omitted
  20360. */
  20361. isOptional: boolean;
  20362. /**
  20363. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20364. */
  20365. define: string;
  20366. /** @hidden */
  20367. _prioritizeVertex: boolean;
  20368. private _target;
  20369. /** Gets or sets the target of that connection point */
  20370. get target(): NodeMaterialBlockTargets;
  20371. set target(value: NodeMaterialBlockTargets);
  20372. /**
  20373. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20374. */
  20375. get isConnected(): boolean;
  20376. /**
  20377. * Gets a boolean indicating that the current point is connected to an input block
  20378. */
  20379. get isConnectedToInputBlock(): boolean;
  20380. /**
  20381. * Gets a the connected input block (if any)
  20382. */
  20383. get connectInputBlock(): Nullable<InputBlock>;
  20384. /** Get the other side of the connection (if any) */
  20385. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20386. /** Get the block that owns this connection point */
  20387. get ownerBlock(): NodeMaterialBlock;
  20388. /** Get the block connected on the other side of this connection (if any) */
  20389. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20390. /** Get the block connected on the endpoints of this connection (if any) */
  20391. get connectedBlocks(): Array<NodeMaterialBlock>;
  20392. /** Gets the list of connected endpoints */
  20393. get endpoints(): NodeMaterialConnectionPoint[];
  20394. /** Gets a boolean indicating if that output point is connected to at least one input */
  20395. get hasEndpoints(): boolean;
  20396. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20397. get isConnectedInVertexShader(): boolean;
  20398. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20399. get isConnectedInFragmentShader(): boolean;
  20400. /**
  20401. * Creates a block suitable to be used as an input for this input point.
  20402. * If null is returned, a block based on the point type will be created.
  20403. * @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
  20404. */
  20405. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20406. /**
  20407. * Creates a new connection point
  20408. * @param name defines the connection point name
  20409. * @param ownerBlock defines the block hosting this connection point
  20410. * @param direction defines the direction of the connection point
  20411. */
  20412. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20413. /**
  20414. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20415. * @returns the class name
  20416. */
  20417. getClassName(): string;
  20418. /**
  20419. * Gets a boolean indicating if the current point can be connected to another point
  20420. * @param connectionPoint defines the other connection point
  20421. * @returns a boolean
  20422. */
  20423. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20424. /**
  20425. * Gets a number indicating if the current point can be connected to another point
  20426. * @param connectionPoint defines the other connection point
  20427. * @returns a number defining the compatibility state
  20428. */
  20429. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20430. /**
  20431. * Connect this point to another connection point
  20432. * @param connectionPoint defines the other connection point
  20433. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20434. * @returns the current connection point
  20435. */
  20436. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20437. /**
  20438. * Disconnect this point from one of his endpoint
  20439. * @param endpoint defines the other connection point
  20440. * @returns the current connection point
  20441. */
  20442. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20443. /**
  20444. * Serializes this point in a JSON representation
  20445. * @param isInput defines if the connection point is an input (default is true)
  20446. * @returns the serialized point object
  20447. */
  20448. serialize(isInput?: boolean): any;
  20449. /**
  20450. * Release resources
  20451. */
  20452. dispose(): void;
  20453. }
  20454. }
  20455. declare module BABYLON {
  20456. /**
  20457. * Enum used to define the material modes
  20458. */
  20459. export enum NodeMaterialModes {
  20460. /** Regular material */
  20461. Material = 0,
  20462. /** For post process */
  20463. PostProcess = 1,
  20464. /** For particle system */
  20465. Particle = 2
  20466. }
  20467. }
  20468. declare module BABYLON {
  20469. /**
  20470. * Block used to read a texture from a sampler
  20471. */
  20472. export class TextureBlock extends NodeMaterialBlock {
  20473. private _defineName;
  20474. private _linearDefineName;
  20475. private _gammaDefineName;
  20476. private _tempTextureRead;
  20477. private _samplerName;
  20478. private _transformedUVName;
  20479. private _textureTransformName;
  20480. private _textureInfoName;
  20481. private _mainUVName;
  20482. private _mainUVDefineName;
  20483. private _fragmentOnly;
  20484. /**
  20485. * Gets or sets the texture associated with the node
  20486. */
  20487. texture: Nullable<Texture>;
  20488. /**
  20489. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20490. */
  20491. convertToGammaSpace: boolean;
  20492. /**
  20493. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20494. */
  20495. convertToLinearSpace: boolean;
  20496. /**
  20497. * Create a new TextureBlock
  20498. * @param name defines the block name
  20499. */
  20500. constructor(name: string, fragmentOnly?: boolean);
  20501. /**
  20502. * Gets the current class name
  20503. * @returns the class name
  20504. */
  20505. getClassName(): string;
  20506. /**
  20507. * Gets the uv input component
  20508. */
  20509. get uv(): NodeMaterialConnectionPoint;
  20510. /**
  20511. * Gets the rgba output component
  20512. */
  20513. get rgba(): NodeMaterialConnectionPoint;
  20514. /**
  20515. * Gets the rgb output component
  20516. */
  20517. get rgb(): NodeMaterialConnectionPoint;
  20518. /**
  20519. * Gets the r output component
  20520. */
  20521. get r(): NodeMaterialConnectionPoint;
  20522. /**
  20523. * Gets the g output component
  20524. */
  20525. get g(): NodeMaterialConnectionPoint;
  20526. /**
  20527. * Gets the b output component
  20528. */
  20529. get b(): NodeMaterialConnectionPoint;
  20530. /**
  20531. * Gets the a output component
  20532. */
  20533. get a(): NodeMaterialConnectionPoint;
  20534. get target(): NodeMaterialBlockTargets;
  20535. autoConfigure(material: NodeMaterial): void;
  20536. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  20537. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20538. isReady(): boolean;
  20539. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20540. private get _isMixed();
  20541. private _injectVertexCode;
  20542. private _writeTextureRead;
  20543. private _writeOutput;
  20544. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20545. protected _dumpPropertiesCode(): string;
  20546. serialize(): any;
  20547. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20548. }
  20549. }
  20550. declare module BABYLON {
  20551. /** @hidden */
  20552. export var reflectionFunction: {
  20553. name: string;
  20554. shader: string;
  20555. };
  20556. }
  20557. declare module BABYLON {
  20558. /**
  20559. * Base block used to read a reflection texture from a sampler
  20560. */
  20561. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  20562. /** @hidden */
  20563. _define3DName: string;
  20564. /** @hidden */
  20565. _defineCubicName: string;
  20566. /** @hidden */
  20567. _defineExplicitName: string;
  20568. /** @hidden */
  20569. _defineProjectionName: string;
  20570. /** @hidden */
  20571. _defineLocalCubicName: string;
  20572. /** @hidden */
  20573. _defineSphericalName: string;
  20574. /** @hidden */
  20575. _definePlanarName: string;
  20576. /** @hidden */
  20577. _defineEquirectangularName: string;
  20578. /** @hidden */
  20579. _defineMirroredEquirectangularFixedName: string;
  20580. /** @hidden */
  20581. _defineEquirectangularFixedName: string;
  20582. /** @hidden */
  20583. _defineSkyboxName: string;
  20584. /** @hidden */
  20585. _defineOppositeZ: string;
  20586. /** @hidden */
  20587. _cubeSamplerName: string;
  20588. /** @hidden */
  20589. _2DSamplerName: string;
  20590. protected _positionUVWName: string;
  20591. protected _directionWName: string;
  20592. protected _reflectionVectorName: string;
  20593. /** @hidden */
  20594. _reflectionCoordsName: string;
  20595. /** @hidden */
  20596. _reflectionMatrixName: string;
  20597. protected _reflectionColorName: string;
  20598. /**
  20599. * Gets or sets the texture associated with the node
  20600. */
  20601. texture: Nullable<BaseTexture>;
  20602. /**
  20603. * Create a new ReflectionTextureBaseBlock
  20604. * @param name defines the block name
  20605. */
  20606. constructor(name: string);
  20607. /**
  20608. * Gets the current class name
  20609. * @returns the class name
  20610. */
  20611. getClassName(): string;
  20612. /**
  20613. * Gets the world position input component
  20614. */
  20615. abstract get position(): NodeMaterialConnectionPoint;
  20616. /**
  20617. * Gets the world position input component
  20618. */
  20619. abstract get worldPosition(): NodeMaterialConnectionPoint;
  20620. /**
  20621. * Gets the world normal input component
  20622. */
  20623. abstract get worldNormal(): NodeMaterialConnectionPoint;
  20624. /**
  20625. * Gets the world input component
  20626. */
  20627. abstract get world(): NodeMaterialConnectionPoint;
  20628. /**
  20629. * Gets the camera (or eye) position component
  20630. */
  20631. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  20632. /**
  20633. * Gets the view input component
  20634. */
  20635. abstract get view(): NodeMaterialConnectionPoint;
  20636. protected _getTexture(): Nullable<BaseTexture>;
  20637. autoConfigure(material: NodeMaterial): void;
  20638. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20639. isReady(): boolean;
  20640. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20641. /**
  20642. * Gets the code to inject in the vertex shader
  20643. * @param state current state of the node material building
  20644. * @returns the shader code
  20645. */
  20646. handleVertexSide(state: NodeMaterialBuildState): string;
  20647. /**
  20648. * Handles the inits for the fragment code path
  20649. * @param state node material build state
  20650. */
  20651. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  20652. /**
  20653. * Generates the reflection coords code for the fragment code path
  20654. * @param worldNormalVarName name of the world normal variable
  20655. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  20656. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  20657. * @returns the shader code
  20658. */
  20659. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  20660. /**
  20661. * Generates the reflection color code for the fragment code path
  20662. * @param lodVarName name of the lod variable
  20663. * @param swizzleLookupTexture swizzle to use for the final color variable
  20664. * @returns the shader code
  20665. */
  20666. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  20667. /**
  20668. * Generates the code corresponding to the connected output points
  20669. * @param state node material build state
  20670. * @param varName name of the variable to output
  20671. * @returns the shader code
  20672. */
  20673. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  20674. protected _buildBlock(state: NodeMaterialBuildState): this;
  20675. protected _dumpPropertiesCode(): string;
  20676. serialize(): any;
  20677. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20678. }
  20679. }
  20680. declare module BABYLON {
  20681. /**
  20682. * Defines a connection point to be used for points with a custom object type
  20683. */
  20684. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  20685. private _blockType;
  20686. private _blockName;
  20687. private _nameForCheking?;
  20688. /**
  20689. * Creates a new connection point
  20690. * @param name defines the connection point name
  20691. * @param ownerBlock defines the block hosting this connection point
  20692. * @param direction defines the direction of the connection point
  20693. */
  20694. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  20695. /**
  20696. * Gets a number indicating if the current point can be connected to another point
  20697. * @param connectionPoint defines the other connection point
  20698. * @returns a number defining the compatibility state
  20699. */
  20700. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20701. /**
  20702. * Creates a block suitable to be used as an input for this input point.
  20703. * If null is returned, a block based on the point type will be created.
  20704. * @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
  20705. */
  20706. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20707. }
  20708. }
  20709. declare module BABYLON {
  20710. /**
  20711. * Enum defining the type of properties that can be edited in the property pages in the NME
  20712. */
  20713. export enum PropertyTypeForEdition {
  20714. /** property is a boolean */
  20715. Boolean = 0,
  20716. /** property is a float */
  20717. Float = 1,
  20718. /** property is a Vector2 */
  20719. Vector2 = 2,
  20720. /** property is a list of values */
  20721. List = 3
  20722. }
  20723. /**
  20724. * Interface that defines an option in a variable of type list
  20725. */
  20726. export interface IEditablePropertyListOption {
  20727. /** label of the option */
  20728. "label": string;
  20729. /** value of the option */
  20730. "value": number;
  20731. }
  20732. /**
  20733. * Interface that defines the options available for an editable property
  20734. */
  20735. export interface IEditablePropertyOption {
  20736. /** min value */
  20737. "min"?: number;
  20738. /** max value */
  20739. "max"?: number;
  20740. /** notifiers: indicates which actions to take when the property is changed */
  20741. "notifiers"?: {
  20742. /** the material should be rebuilt */
  20743. "rebuild"?: boolean;
  20744. /** the preview should be updated */
  20745. "update"?: boolean;
  20746. };
  20747. /** list of the options for a variable of type list */
  20748. "options"?: IEditablePropertyListOption[];
  20749. }
  20750. /**
  20751. * Interface that describes an editable property
  20752. */
  20753. export interface IPropertyDescriptionForEdition {
  20754. /** name of the property */
  20755. "propertyName": string;
  20756. /** display name of the property */
  20757. "displayName": string;
  20758. /** type of the property */
  20759. "type": PropertyTypeForEdition;
  20760. /** group of the property - all properties with the same group value will be displayed in a specific section */
  20761. "groupName": string;
  20762. /** options for the property */
  20763. "options": IEditablePropertyOption;
  20764. }
  20765. /**
  20766. * Decorator that flags a property in a node material block as being editable
  20767. */
  20768. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  20769. }
  20770. declare module BABYLON {
  20771. /**
  20772. * Block used to implement the refraction part of the sub surface module of the PBR material
  20773. */
  20774. export class RefractionBlock extends NodeMaterialBlock {
  20775. /** @hidden */
  20776. _define3DName: string;
  20777. /** @hidden */
  20778. _refractionMatrixName: string;
  20779. /** @hidden */
  20780. _defineLODRefractionAlpha: string;
  20781. /** @hidden */
  20782. _defineLinearSpecularRefraction: string;
  20783. /** @hidden */
  20784. _defineOppositeZ: string;
  20785. /** @hidden */
  20786. _cubeSamplerName: string;
  20787. /** @hidden */
  20788. _2DSamplerName: string;
  20789. /** @hidden */
  20790. _vRefractionMicrosurfaceInfosName: string;
  20791. /** @hidden */
  20792. _vRefractionInfosName: string;
  20793. private _scene;
  20794. /**
  20795. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20796. * Materials half opaque for instance using refraction could benefit from this control.
  20797. */
  20798. linkRefractionWithTransparency: boolean;
  20799. /**
  20800. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20801. */
  20802. invertRefractionY: boolean;
  20803. /**
  20804. * Gets or sets the texture associated with the node
  20805. */
  20806. texture: Nullable<BaseTexture>;
  20807. /**
  20808. * Create a new RefractionBlock
  20809. * @param name defines the block name
  20810. */
  20811. constructor(name: string);
  20812. /**
  20813. * Gets the current class name
  20814. * @returns the class name
  20815. */
  20816. getClassName(): string;
  20817. /**
  20818. * Gets the intensity input component
  20819. */
  20820. get intensity(): NodeMaterialConnectionPoint;
  20821. /**
  20822. * Gets the index of refraction input component
  20823. */
  20824. get indexOfRefraction(): NodeMaterialConnectionPoint;
  20825. /**
  20826. * Gets the tint at distance input component
  20827. */
  20828. get tintAtDistance(): NodeMaterialConnectionPoint;
  20829. /**
  20830. * Gets the view input component
  20831. */
  20832. get view(): NodeMaterialConnectionPoint;
  20833. /**
  20834. * Gets the refraction object output component
  20835. */
  20836. get refraction(): NodeMaterialConnectionPoint;
  20837. /**
  20838. * Returns true if the block has a texture
  20839. */
  20840. get hasTexture(): boolean;
  20841. protected _getTexture(): Nullable<BaseTexture>;
  20842. autoConfigure(material: NodeMaterial): void;
  20843. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20844. isReady(): boolean;
  20845. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  20846. /**
  20847. * Gets the main code of the block (fragment side)
  20848. * @param state current state of the node material building
  20849. * @returns the shader code
  20850. */
  20851. getCode(state: NodeMaterialBuildState): string;
  20852. protected _buildBlock(state: NodeMaterialBuildState): this;
  20853. protected _dumpPropertiesCode(): string;
  20854. serialize(): any;
  20855. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20856. }
  20857. }
  20858. declare module BABYLON {
  20859. /**
  20860. * Base block used as input for post process
  20861. */
  20862. export class CurrentScreenBlock extends NodeMaterialBlock {
  20863. private _samplerName;
  20864. private _linearDefineName;
  20865. private _gammaDefineName;
  20866. private _mainUVName;
  20867. private _tempTextureRead;
  20868. /**
  20869. * Gets or sets the texture associated with the node
  20870. */
  20871. texture: Nullable<BaseTexture>;
  20872. /**
  20873. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20874. */
  20875. convertToGammaSpace: boolean;
  20876. /**
  20877. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20878. */
  20879. convertToLinearSpace: boolean;
  20880. /**
  20881. * Create a new CurrentScreenBlock
  20882. * @param name defines the block name
  20883. */
  20884. constructor(name: string);
  20885. /**
  20886. * Gets the current class name
  20887. * @returns the class name
  20888. */
  20889. getClassName(): string;
  20890. /**
  20891. * Gets the uv input component
  20892. */
  20893. get uv(): NodeMaterialConnectionPoint;
  20894. /**
  20895. * Gets the rgba output component
  20896. */
  20897. get rgba(): NodeMaterialConnectionPoint;
  20898. /**
  20899. * Gets the rgb output component
  20900. */
  20901. get rgb(): NodeMaterialConnectionPoint;
  20902. /**
  20903. * Gets the r output component
  20904. */
  20905. get r(): NodeMaterialConnectionPoint;
  20906. /**
  20907. * Gets the g output component
  20908. */
  20909. get g(): NodeMaterialConnectionPoint;
  20910. /**
  20911. * Gets the b output component
  20912. */
  20913. get b(): NodeMaterialConnectionPoint;
  20914. /**
  20915. * Gets the a output component
  20916. */
  20917. get a(): NodeMaterialConnectionPoint;
  20918. /**
  20919. * Initialize the block and prepare the context for build
  20920. * @param state defines the state that will be used for the build
  20921. */
  20922. initialize(state: NodeMaterialBuildState): void;
  20923. get target(): NodeMaterialBlockTargets;
  20924. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20925. isReady(): boolean;
  20926. private _injectVertexCode;
  20927. private _writeTextureRead;
  20928. private _writeOutput;
  20929. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20930. serialize(): any;
  20931. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20932. }
  20933. }
  20934. declare module BABYLON {
  20935. /**
  20936. * Base block used for the particle texture
  20937. */
  20938. export class ParticleTextureBlock extends NodeMaterialBlock {
  20939. private _samplerName;
  20940. private _linearDefineName;
  20941. private _gammaDefineName;
  20942. private _tempTextureRead;
  20943. /**
  20944. * Gets or sets the texture associated with the node
  20945. */
  20946. texture: Nullable<BaseTexture>;
  20947. /**
  20948. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20949. */
  20950. convertToGammaSpace: boolean;
  20951. /**
  20952. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20953. */
  20954. convertToLinearSpace: boolean;
  20955. /**
  20956. * Create a new ParticleTextureBlock
  20957. * @param name defines the block name
  20958. */
  20959. constructor(name: string);
  20960. /**
  20961. * Gets the current class name
  20962. * @returns the class name
  20963. */
  20964. getClassName(): string;
  20965. /**
  20966. * Gets the uv input component
  20967. */
  20968. get uv(): NodeMaterialConnectionPoint;
  20969. /**
  20970. * Gets the rgba output component
  20971. */
  20972. get rgba(): NodeMaterialConnectionPoint;
  20973. /**
  20974. * Gets the rgb output component
  20975. */
  20976. get rgb(): NodeMaterialConnectionPoint;
  20977. /**
  20978. * Gets the r output component
  20979. */
  20980. get r(): NodeMaterialConnectionPoint;
  20981. /**
  20982. * Gets the g output component
  20983. */
  20984. get g(): NodeMaterialConnectionPoint;
  20985. /**
  20986. * Gets the b output component
  20987. */
  20988. get b(): NodeMaterialConnectionPoint;
  20989. /**
  20990. * Gets the a output component
  20991. */
  20992. get a(): NodeMaterialConnectionPoint;
  20993. /**
  20994. * Initialize the block and prepare the context for build
  20995. * @param state defines the state that will be used for the build
  20996. */
  20997. initialize(state: NodeMaterialBuildState): void;
  20998. autoConfigure(material: NodeMaterial): void;
  20999. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21000. isReady(): boolean;
  21001. private _writeOutput;
  21002. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21003. serialize(): any;
  21004. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21005. }
  21006. }
  21007. declare module BABYLON {
  21008. /**
  21009. * Class used to store shared data between 2 NodeMaterialBuildState
  21010. */
  21011. export class NodeMaterialBuildStateSharedData {
  21012. /**
  21013. * Gets the list of emitted varyings
  21014. */
  21015. temps: string[];
  21016. /**
  21017. * Gets the list of emitted varyings
  21018. */
  21019. varyings: string[];
  21020. /**
  21021. * Gets the varying declaration string
  21022. */
  21023. varyingDeclaration: string;
  21024. /**
  21025. * Input blocks
  21026. */
  21027. inputBlocks: InputBlock[];
  21028. /**
  21029. * Input blocks
  21030. */
  21031. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21032. /**
  21033. * Bindable blocks (Blocks that need to set data to the effect)
  21034. */
  21035. bindableBlocks: NodeMaterialBlock[];
  21036. /**
  21037. * List of blocks that can provide a compilation fallback
  21038. */
  21039. blocksWithFallbacks: NodeMaterialBlock[];
  21040. /**
  21041. * List of blocks that can provide a define update
  21042. */
  21043. blocksWithDefines: NodeMaterialBlock[];
  21044. /**
  21045. * List of blocks that can provide a repeatable content
  21046. */
  21047. repeatableContentBlocks: NodeMaterialBlock[];
  21048. /**
  21049. * List of blocks that can provide a dynamic list of uniforms
  21050. */
  21051. dynamicUniformBlocks: NodeMaterialBlock[];
  21052. /**
  21053. * List of blocks that can block the isReady function for the material
  21054. */
  21055. blockingBlocks: NodeMaterialBlock[];
  21056. /**
  21057. * Gets the list of animated inputs
  21058. */
  21059. animatedInputs: InputBlock[];
  21060. /**
  21061. * Build Id used to avoid multiple recompilations
  21062. */
  21063. buildId: number;
  21064. /** List of emitted variables */
  21065. variableNames: {
  21066. [key: string]: number;
  21067. };
  21068. /** List of emitted defines */
  21069. defineNames: {
  21070. [key: string]: number;
  21071. };
  21072. /** Should emit comments? */
  21073. emitComments: boolean;
  21074. /** Emit build activity */
  21075. verbose: boolean;
  21076. /** Gets or sets the hosting scene */
  21077. scene: Scene;
  21078. /**
  21079. * Gets the compilation hints emitted at compilation time
  21080. */
  21081. hints: {
  21082. needWorldViewMatrix: boolean;
  21083. needWorldViewProjectionMatrix: boolean;
  21084. needAlphaBlending: boolean;
  21085. needAlphaTesting: boolean;
  21086. };
  21087. /**
  21088. * List of compilation checks
  21089. */
  21090. checks: {
  21091. emitVertex: boolean;
  21092. emitFragment: boolean;
  21093. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21094. };
  21095. /**
  21096. * Is vertex program allowed to be empty?
  21097. */
  21098. allowEmptyVertexProgram: boolean;
  21099. /** Creates a new shared data */
  21100. constructor();
  21101. /**
  21102. * Emits console errors and exceptions if there is a failing check
  21103. */
  21104. emitErrors(): void;
  21105. }
  21106. }
  21107. declare module BABYLON {
  21108. /**
  21109. * Class used to store node based material build state
  21110. */
  21111. export class NodeMaterialBuildState {
  21112. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21113. supportUniformBuffers: boolean;
  21114. /**
  21115. * Gets the list of emitted attributes
  21116. */
  21117. attributes: string[];
  21118. /**
  21119. * Gets the list of emitted uniforms
  21120. */
  21121. uniforms: string[];
  21122. /**
  21123. * Gets the list of emitted constants
  21124. */
  21125. constants: string[];
  21126. /**
  21127. * Gets the list of emitted samplers
  21128. */
  21129. samplers: string[];
  21130. /**
  21131. * Gets the list of emitted functions
  21132. */
  21133. functions: {
  21134. [key: string]: string;
  21135. };
  21136. /**
  21137. * Gets the list of emitted extensions
  21138. */
  21139. extensions: {
  21140. [key: string]: string;
  21141. };
  21142. /**
  21143. * Gets the target of the compilation state
  21144. */
  21145. target: NodeMaterialBlockTargets;
  21146. /**
  21147. * Gets the list of emitted counters
  21148. */
  21149. counters: {
  21150. [key: string]: number;
  21151. };
  21152. /**
  21153. * Shared data between multiple NodeMaterialBuildState instances
  21154. */
  21155. sharedData: NodeMaterialBuildStateSharedData;
  21156. /** @hidden */
  21157. _vertexState: NodeMaterialBuildState;
  21158. /** @hidden */
  21159. _attributeDeclaration: string;
  21160. /** @hidden */
  21161. _uniformDeclaration: string;
  21162. /** @hidden */
  21163. _constantDeclaration: string;
  21164. /** @hidden */
  21165. _samplerDeclaration: string;
  21166. /** @hidden */
  21167. _varyingTransfer: string;
  21168. /** @hidden */
  21169. _injectAtEnd: string;
  21170. private _repeatableContentAnchorIndex;
  21171. /** @hidden */
  21172. _builtCompilationString: string;
  21173. /**
  21174. * Gets the emitted compilation strings
  21175. */
  21176. compilationString: string;
  21177. /**
  21178. * Finalize the compilation strings
  21179. * @param state defines the current compilation state
  21180. */
  21181. finalize(state: NodeMaterialBuildState): void;
  21182. /** @hidden */
  21183. get _repeatableContentAnchor(): string;
  21184. /** @hidden */
  21185. _getFreeVariableName(prefix: string): string;
  21186. /** @hidden */
  21187. _getFreeDefineName(prefix: string): string;
  21188. /** @hidden */
  21189. _excludeVariableName(name: string): void;
  21190. /** @hidden */
  21191. _emit2DSampler(name: string): void;
  21192. /** @hidden */
  21193. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21194. /** @hidden */
  21195. _emitExtension(name: string, extension: string, define?: string): void;
  21196. /** @hidden */
  21197. _emitFunction(name: string, code: string, comments: string): void;
  21198. /** @hidden */
  21199. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21200. replaceStrings?: {
  21201. search: RegExp;
  21202. replace: string;
  21203. }[];
  21204. repeatKey?: string;
  21205. }): string;
  21206. /** @hidden */
  21207. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21208. repeatKey?: string;
  21209. removeAttributes?: boolean;
  21210. removeUniforms?: boolean;
  21211. removeVaryings?: boolean;
  21212. removeIfDef?: boolean;
  21213. replaceStrings?: {
  21214. search: RegExp;
  21215. replace: string;
  21216. }[];
  21217. }, storeKey?: string): void;
  21218. /** @hidden */
  21219. _registerTempVariable(name: string): boolean;
  21220. /** @hidden */
  21221. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21222. /** @hidden */
  21223. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21224. /** @hidden */
  21225. _emitFloat(value: number): string;
  21226. }
  21227. }
  21228. declare module BABYLON {
  21229. /**
  21230. * Helper class used to generate session unique ID
  21231. */
  21232. export class UniqueIdGenerator {
  21233. private static _UniqueIdCounter;
  21234. /**
  21235. * Gets an unique (relatively to the current scene) Id
  21236. */
  21237. static get UniqueId(): number;
  21238. }
  21239. }
  21240. declare module BABYLON {
  21241. /**
  21242. * Defines a block that can be used inside a node based material
  21243. */
  21244. export class NodeMaterialBlock {
  21245. private _buildId;
  21246. private _buildTarget;
  21247. private _target;
  21248. private _isFinalMerger;
  21249. private _isInput;
  21250. protected _isUnique: boolean;
  21251. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21252. inputsAreExclusive: boolean;
  21253. /** @hidden */
  21254. _codeVariableName: string;
  21255. /** @hidden */
  21256. _inputs: NodeMaterialConnectionPoint[];
  21257. /** @hidden */
  21258. _outputs: NodeMaterialConnectionPoint[];
  21259. /** @hidden */
  21260. _preparationId: number;
  21261. /**
  21262. * Gets or sets the name of the block
  21263. */
  21264. name: string;
  21265. /**
  21266. * Gets or sets the unique id of the node
  21267. */
  21268. uniqueId: number;
  21269. /**
  21270. * Gets or sets the comments associated with this block
  21271. */
  21272. comments: string;
  21273. /**
  21274. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21275. */
  21276. get isUnique(): boolean;
  21277. /**
  21278. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21279. */
  21280. get isFinalMerger(): boolean;
  21281. /**
  21282. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21283. */
  21284. get isInput(): boolean;
  21285. /**
  21286. * Gets or sets the build Id
  21287. */
  21288. get buildId(): number;
  21289. set buildId(value: number);
  21290. /**
  21291. * Gets or sets the target of the block
  21292. */
  21293. get target(): NodeMaterialBlockTargets;
  21294. set target(value: NodeMaterialBlockTargets);
  21295. /**
  21296. * Gets the list of input points
  21297. */
  21298. get inputs(): NodeMaterialConnectionPoint[];
  21299. /** Gets the list of output points */
  21300. get outputs(): NodeMaterialConnectionPoint[];
  21301. /**
  21302. * Find an input by its name
  21303. * @param name defines the name of the input to look for
  21304. * @returns the input or null if not found
  21305. */
  21306. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21307. /**
  21308. * Find an output by its name
  21309. * @param name defines the name of the outputto look for
  21310. * @returns the output or null if not found
  21311. */
  21312. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21313. /**
  21314. * Creates a new NodeMaterialBlock
  21315. * @param name defines the block name
  21316. * @param target defines the target of that block (Vertex by default)
  21317. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21318. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21319. */
  21320. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21321. /**
  21322. * Initialize the block and prepare the context for build
  21323. * @param state defines the state that will be used for the build
  21324. */
  21325. initialize(state: NodeMaterialBuildState): void;
  21326. /**
  21327. * Bind data to effect. Will only be called for blocks with isBindable === true
  21328. * @param effect defines the effect to bind data to
  21329. * @param nodeMaterial defines the hosting NodeMaterial
  21330. * @param mesh defines the mesh that will be rendered
  21331. * @param subMesh defines the submesh that will be rendered
  21332. */
  21333. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21334. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21335. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21336. protected _writeFloat(value: number): string;
  21337. /**
  21338. * Gets the current class name e.g. "NodeMaterialBlock"
  21339. * @returns the class name
  21340. */
  21341. getClassName(): string;
  21342. /**
  21343. * Register a new input. Must be called inside a block constructor
  21344. * @param name defines the connection point name
  21345. * @param type defines the connection point type
  21346. * @param isOptional defines a boolean indicating that this input can be omitted
  21347. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21348. * @param point an already created connection point. If not provided, create a new one
  21349. * @returns the current block
  21350. */
  21351. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21352. /**
  21353. * Register a new output. Must be called inside a block constructor
  21354. * @param name defines the connection point name
  21355. * @param type defines the connection point type
  21356. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21357. * @param point an already created connection point. If not provided, create a new one
  21358. * @returns the current block
  21359. */
  21360. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21361. /**
  21362. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21363. * @param forOutput defines an optional connection point to check compatibility with
  21364. * @returns the first available input or null
  21365. */
  21366. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21367. /**
  21368. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21369. * @param forBlock defines an optional block to check compatibility with
  21370. * @returns the first available input or null
  21371. */
  21372. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21373. /**
  21374. * Gets the sibling of the given output
  21375. * @param current defines the current output
  21376. * @returns the next output in the list or null
  21377. */
  21378. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21379. /**
  21380. * Connect current block with another block
  21381. * @param other defines the block to connect with
  21382. * @param options define the various options to help pick the right connections
  21383. * @returns the current block
  21384. */
  21385. connectTo(other: NodeMaterialBlock, options?: {
  21386. input?: string;
  21387. output?: string;
  21388. outputSwizzle?: string;
  21389. }): this | undefined;
  21390. protected _buildBlock(state: NodeMaterialBuildState): void;
  21391. /**
  21392. * Add uniforms, samplers and uniform buffers at compilation time
  21393. * @param state defines the state to update
  21394. * @param nodeMaterial defines the node material requesting the update
  21395. * @param defines defines the material defines to update
  21396. * @param uniformBuffers defines the list of uniform buffer names
  21397. */
  21398. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21399. /**
  21400. * Add potential fallbacks if shader compilation fails
  21401. * @param mesh defines the mesh to be rendered
  21402. * @param fallbacks defines the current prioritized list of fallbacks
  21403. */
  21404. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21405. /**
  21406. * Initialize defines for shader compilation
  21407. * @param mesh defines the mesh to be rendered
  21408. * @param nodeMaterial defines the node material requesting the update
  21409. * @param defines defines the material defines to update
  21410. * @param useInstances specifies that instances should be used
  21411. */
  21412. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21413. /**
  21414. * Update defines for shader compilation
  21415. * @param mesh defines the mesh to be rendered
  21416. * @param nodeMaterial defines the node material requesting the update
  21417. * @param defines defines the material defines to update
  21418. * @param useInstances specifies that instances should be used
  21419. */
  21420. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21421. /**
  21422. * Lets the block try to connect some inputs automatically
  21423. * @param material defines the hosting NodeMaterial
  21424. */
  21425. autoConfigure(material: NodeMaterial): void;
  21426. /**
  21427. * Function called when a block is declared as repeatable content generator
  21428. * @param vertexShaderState defines the current compilation state for the vertex shader
  21429. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21430. * @param mesh defines the mesh to be rendered
  21431. * @param defines defines the material defines to update
  21432. */
  21433. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21434. /**
  21435. * Checks if the block is ready
  21436. * @param mesh defines the mesh to be rendered
  21437. * @param nodeMaterial defines the node material requesting the update
  21438. * @param defines defines the material defines to update
  21439. * @param useInstances specifies that instances should be used
  21440. * @returns true if the block is ready
  21441. */
  21442. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21443. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21444. private _processBuild;
  21445. /**
  21446. * Compile the current node and generate the shader code
  21447. * @param state defines the current compilation state (uniforms, samplers, current string)
  21448. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21449. * @returns true if already built
  21450. */
  21451. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21452. protected _inputRename(name: string): string;
  21453. protected _outputRename(name: string): string;
  21454. protected _dumpPropertiesCode(): string;
  21455. /** @hidden */
  21456. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21457. /** @hidden */
  21458. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21459. /**
  21460. * Clone the current block to a new identical block
  21461. * @param scene defines the hosting scene
  21462. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21463. * @returns a copy of the current block
  21464. */
  21465. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21466. /**
  21467. * Serializes this block in a JSON representation
  21468. * @returns the serialized block object
  21469. */
  21470. serialize(): any;
  21471. /** @hidden */
  21472. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21473. private _deserializePortDisplayNames;
  21474. /**
  21475. * Release resources
  21476. */
  21477. dispose(): void;
  21478. }
  21479. }
  21480. declare module BABYLON {
  21481. /**
  21482. * Base class of materials working in push mode in babylon JS
  21483. * @hidden
  21484. */
  21485. export class PushMaterial extends Material {
  21486. protected _activeEffect: Effect;
  21487. protected _normalMatrix: Matrix;
  21488. /**
  21489. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  21490. * This means that the material can keep using a previous shader while a new one is being compiled.
  21491. * This is mostly used when shader parallel compilation is supported (true by default)
  21492. */
  21493. allowShaderHotSwapping: boolean;
  21494. constructor(name: string, scene: Scene);
  21495. getEffect(): Effect;
  21496. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21497. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21498. /**
  21499. * Binds the given world matrix to the active effect
  21500. *
  21501. * @param world the matrix to bind
  21502. */
  21503. bindOnlyWorldMatrix(world: Matrix): void;
  21504. /**
  21505. * Binds the given normal matrix to the active effect
  21506. *
  21507. * @param normalMatrix the matrix to bind
  21508. */
  21509. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21510. bind(world: Matrix, mesh?: Mesh): void;
  21511. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21512. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21513. }
  21514. }
  21515. declare module BABYLON {
  21516. /**
  21517. * Root class for all node material optimizers
  21518. */
  21519. export class NodeMaterialOptimizer {
  21520. /**
  21521. * Function used to optimize a NodeMaterial graph
  21522. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21523. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21524. */
  21525. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21526. }
  21527. }
  21528. declare module BABYLON {
  21529. /**
  21530. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  21531. */
  21532. export class TransformBlock extends NodeMaterialBlock {
  21533. /**
  21534. * Defines the value to use to complement W value to transform it to a Vector4
  21535. */
  21536. complementW: number;
  21537. /**
  21538. * Defines the value to use to complement z value to transform it to a Vector4
  21539. */
  21540. complementZ: number;
  21541. /**
  21542. * Creates a new TransformBlock
  21543. * @param name defines the block name
  21544. */
  21545. constructor(name: string);
  21546. /**
  21547. * Gets the current class name
  21548. * @returns the class name
  21549. */
  21550. getClassName(): string;
  21551. /**
  21552. * Gets the vector input
  21553. */
  21554. get vector(): NodeMaterialConnectionPoint;
  21555. /**
  21556. * Gets the output component
  21557. */
  21558. get output(): NodeMaterialConnectionPoint;
  21559. /**
  21560. * Gets the xyz output component
  21561. */
  21562. get xyz(): NodeMaterialConnectionPoint;
  21563. /**
  21564. * Gets the matrix transform input
  21565. */
  21566. get transform(): NodeMaterialConnectionPoint;
  21567. protected _buildBlock(state: NodeMaterialBuildState): this;
  21568. serialize(): any;
  21569. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21570. protected _dumpPropertiesCode(): string;
  21571. }
  21572. }
  21573. declare module BABYLON {
  21574. /**
  21575. * Block used to output the vertex position
  21576. */
  21577. export class VertexOutputBlock extends NodeMaterialBlock {
  21578. /**
  21579. * Creates a new VertexOutputBlock
  21580. * @param name defines the block name
  21581. */
  21582. constructor(name: string);
  21583. /**
  21584. * Gets the current class name
  21585. * @returns the class name
  21586. */
  21587. getClassName(): string;
  21588. /**
  21589. * Gets the vector input component
  21590. */
  21591. get vector(): NodeMaterialConnectionPoint;
  21592. protected _buildBlock(state: NodeMaterialBuildState): this;
  21593. }
  21594. }
  21595. declare module BABYLON {
  21596. /**
  21597. * Block used to output the final color
  21598. */
  21599. export class FragmentOutputBlock extends NodeMaterialBlock {
  21600. /**
  21601. * Create a new FragmentOutputBlock
  21602. * @param name defines the block name
  21603. */
  21604. constructor(name: string);
  21605. /**
  21606. * Gets the current class name
  21607. * @returns the class name
  21608. */
  21609. getClassName(): string;
  21610. /**
  21611. * Gets the rgba input component
  21612. */
  21613. get rgba(): NodeMaterialConnectionPoint;
  21614. /**
  21615. * Gets the rgb input component
  21616. */
  21617. get rgb(): NodeMaterialConnectionPoint;
  21618. /**
  21619. * Gets the a input component
  21620. */
  21621. get a(): NodeMaterialConnectionPoint;
  21622. protected _buildBlock(state: NodeMaterialBuildState): this;
  21623. }
  21624. }
  21625. declare module BABYLON {
  21626. /**
  21627. * Block used for the particle ramp gradient section
  21628. */
  21629. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  21630. /**
  21631. * Create a new ParticleRampGradientBlock
  21632. * @param name defines the block name
  21633. */
  21634. constructor(name: string);
  21635. /**
  21636. * Gets the current class name
  21637. * @returns the class name
  21638. */
  21639. getClassName(): string;
  21640. /**
  21641. * Gets the color input component
  21642. */
  21643. get color(): NodeMaterialConnectionPoint;
  21644. /**
  21645. * Gets the rampColor output component
  21646. */
  21647. get rampColor(): NodeMaterialConnectionPoint;
  21648. /**
  21649. * Initialize the block and prepare the context for build
  21650. * @param state defines the state that will be used for the build
  21651. */
  21652. initialize(state: NodeMaterialBuildState): void;
  21653. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21654. }
  21655. }
  21656. declare module BABYLON {
  21657. /**
  21658. * Block used for the particle blend multiply section
  21659. */
  21660. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  21661. /**
  21662. * Create a new ParticleBlendMultiplyBlock
  21663. * @param name defines the block name
  21664. */
  21665. constructor(name: string);
  21666. /**
  21667. * Gets the current class name
  21668. * @returns the class name
  21669. */
  21670. getClassName(): string;
  21671. /**
  21672. * Gets the color input component
  21673. */
  21674. get color(): NodeMaterialConnectionPoint;
  21675. /**
  21676. * Gets the alphaTexture input component
  21677. */
  21678. get alphaTexture(): NodeMaterialConnectionPoint;
  21679. /**
  21680. * Gets the alphaColor input component
  21681. */
  21682. get alphaColor(): NodeMaterialConnectionPoint;
  21683. /**
  21684. * Gets the blendColor output component
  21685. */
  21686. get blendColor(): NodeMaterialConnectionPoint;
  21687. /**
  21688. * Initialize the block and prepare the context for build
  21689. * @param state defines the state that will be used for the build
  21690. */
  21691. initialize(state: NodeMaterialBuildState): void;
  21692. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21693. }
  21694. }
  21695. declare module BABYLON {
  21696. /**
  21697. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  21698. */
  21699. export class VectorMergerBlock extends NodeMaterialBlock {
  21700. /**
  21701. * Create a new VectorMergerBlock
  21702. * @param name defines the block name
  21703. */
  21704. constructor(name: string);
  21705. /**
  21706. * Gets the current class name
  21707. * @returns the class name
  21708. */
  21709. getClassName(): string;
  21710. /**
  21711. * Gets the xyz component (input)
  21712. */
  21713. get xyzIn(): NodeMaterialConnectionPoint;
  21714. /**
  21715. * Gets the xy component (input)
  21716. */
  21717. get xyIn(): NodeMaterialConnectionPoint;
  21718. /**
  21719. * Gets the x component (input)
  21720. */
  21721. get x(): NodeMaterialConnectionPoint;
  21722. /**
  21723. * Gets the y component (input)
  21724. */
  21725. get y(): NodeMaterialConnectionPoint;
  21726. /**
  21727. * Gets the z component (input)
  21728. */
  21729. get z(): NodeMaterialConnectionPoint;
  21730. /**
  21731. * Gets the w component (input)
  21732. */
  21733. get w(): NodeMaterialConnectionPoint;
  21734. /**
  21735. * Gets the xyzw component (output)
  21736. */
  21737. get xyzw(): NodeMaterialConnectionPoint;
  21738. /**
  21739. * Gets the xyz component (output)
  21740. */
  21741. get xyzOut(): NodeMaterialConnectionPoint;
  21742. /**
  21743. * Gets the xy component (output)
  21744. */
  21745. get xyOut(): NodeMaterialConnectionPoint;
  21746. /**
  21747. * Gets the xy component (output)
  21748. * @deprecated Please use xyOut instead.
  21749. */
  21750. get xy(): NodeMaterialConnectionPoint;
  21751. /**
  21752. * Gets the xyz component (output)
  21753. * @deprecated Please use xyzOut instead.
  21754. */
  21755. get xyz(): NodeMaterialConnectionPoint;
  21756. protected _buildBlock(state: NodeMaterialBuildState): this;
  21757. }
  21758. }
  21759. declare module BABYLON {
  21760. /**
  21761. * Block used to remap a float from a range to a new one
  21762. */
  21763. export class RemapBlock extends NodeMaterialBlock {
  21764. /**
  21765. * Gets or sets the source range
  21766. */
  21767. sourceRange: Vector2;
  21768. /**
  21769. * Gets or sets the target range
  21770. */
  21771. targetRange: Vector2;
  21772. /**
  21773. * Creates a new RemapBlock
  21774. * @param name defines the block name
  21775. */
  21776. constructor(name: string);
  21777. /**
  21778. * Gets the current class name
  21779. * @returns the class name
  21780. */
  21781. getClassName(): string;
  21782. /**
  21783. * Gets the input component
  21784. */
  21785. get input(): NodeMaterialConnectionPoint;
  21786. /**
  21787. * Gets the source min input component
  21788. */
  21789. get sourceMin(): NodeMaterialConnectionPoint;
  21790. /**
  21791. * Gets the source max input component
  21792. */
  21793. get sourceMax(): NodeMaterialConnectionPoint;
  21794. /**
  21795. * Gets the target min input component
  21796. */
  21797. get targetMin(): NodeMaterialConnectionPoint;
  21798. /**
  21799. * Gets the target max input component
  21800. */
  21801. get targetMax(): NodeMaterialConnectionPoint;
  21802. /**
  21803. * Gets the output component
  21804. */
  21805. get output(): NodeMaterialConnectionPoint;
  21806. protected _buildBlock(state: NodeMaterialBuildState): this;
  21807. protected _dumpPropertiesCode(): string;
  21808. serialize(): any;
  21809. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21810. }
  21811. }
  21812. declare module BABYLON {
  21813. /**
  21814. * Block used to multiply 2 values
  21815. */
  21816. export class MultiplyBlock extends NodeMaterialBlock {
  21817. /**
  21818. * Creates a new MultiplyBlock
  21819. * @param name defines the block name
  21820. */
  21821. constructor(name: string);
  21822. /**
  21823. * Gets the current class name
  21824. * @returns the class name
  21825. */
  21826. getClassName(): string;
  21827. /**
  21828. * Gets the left operand input component
  21829. */
  21830. get left(): NodeMaterialConnectionPoint;
  21831. /**
  21832. * Gets the right operand input component
  21833. */
  21834. get right(): NodeMaterialConnectionPoint;
  21835. /**
  21836. * Gets the output component
  21837. */
  21838. get output(): NodeMaterialConnectionPoint;
  21839. protected _buildBlock(state: NodeMaterialBuildState): this;
  21840. }
  21841. }
  21842. declare module BABYLON {
  21843. /**
  21844. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  21845. */
  21846. export class ColorSplitterBlock extends NodeMaterialBlock {
  21847. /**
  21848. * Create a new ColorSplitterBlock
  21849. * @param name defines the block name
  21850. */
  21851. constructor(name: string);
  21852. /**
  21853. * Gets the current class name
  21854. * @returns the class name
  21855. */
  21856. getClassName(): string;
  21857. /**
  21858. * Gets the rgba component (input)
  21859. */
  21860. get rgba(): NodeMaterialConnectionPoint;
  21861. /**
  21862. * Gets the rgb component (input)
  21863. */
  21864. get rgbIn(): NodeMaterialConnectionPoint;
  21865. /**
  21866. * Gets the rgb component (output)
  21867. */
  21868. get rgbOut(): NodeMaterialConnectionPoint;
  21869. /**
  21870. * Gets the r component (output)
  21871. */
  21872. get r(): NodeMaterialConnectionPoint;
  21873. /**
  21874. * Gets the g component (output)
  21875. */
  21876. get g(): NodeMaterialConnectionPoint;
  21877. /**
  21878. * Gets the b component (output)
  21879. */
  21880. get b(): NodeMaterialConnectionPoint;
  21881. /**
  21882. * Gets the a component (output)
  21883. */
  21884. get a(): NodeMaterialConnectionPoint;
  21885. protected _inputRename(name: string): string;
  21886. protected _outputRename(name: string): string;
  21887. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21888. }
  21889. }
  21890. declare module BABYLON {
  21891. /**
  21892. * Interface used to configure the node material editor
  21893. */
  21894. export interface INodeMaterialEditorOptions {
  21895. /** Define the URl to load node editor script */
  21896. editorURL?: string;
  21897. }
  21898. /** @hidden */
  21899. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  21900. NORMAL: boolean;
  21901. TANGENT: boolean;
  21902. UV1: boolean;
  21903. /** BONES */
  21904. NUM_BONE_INFLUENCERS: number;
  21905. BonesPerMesh: number;
  21906. BONETEXTURE: boolean;
  21907. /** MORPH TARGETS */
  21908. MORPHTARGETS: boolean;
  21909. MORPHTARGETS_NORMAL: boolean;
  21910. MORPHTARGETS_TANGENT: boolean;
  21911. MORPHTARGETS_UV: boolean;
  21912. NUM_MORPH_INFLUENCERS: number;
  21913. /** IMAGE PROCESSING */
  21914. IMAGEPROCESSING: boolean;
  21915. VIGNETTE: boolean;
  21916. VIGNETTEBLENDMODEMULTIPLY: boolean;
  21917. VIGNETTEBLENDMODEOPAQUE: boolean;
  21918. TONEMAPPING: boolean;
  21919. TONEMAPPING_ACES: boolean;
  21920. CONTRAST: boolean;
  21921. EXPOSURE: boolean;
  21922. COLORCURVES: boolean;
  21923. COLORGRADING: boolean;
  21924. COLORGRADING3D: boolean;
  21925. SAMPLER3DGREENDEPTH: boolean;
  21926. SAMPLER3DBGRMAP: boolean;
  21927. IMAGEPROCESSINGPOSTPROCESS: boolean;
  21928. /** MISC. */
  21929. BUMPDIRECTUV: number;
  21930. constructor();
  21931. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  21932. }
  21933. /**
  21934. * Class used to configure NodeMaterial
  21935. */
  21936. export interface INodeMaterialOptions {
  21937. /**
  21938. * Defines if blocks should emit comments
  21939. */
  21940. emitComments: boolean;
  21941. }
  21942. /**
  21943. * Class used to create a node based material built by assembling shader blocks
  21944. */
  21945. export class NodeMaterial extends PushMaterial {
  21946. private static _BuildIdGenerator;
  21947. private _options;
  21948. private _vertexCompilationState;
  21949. private _fragmentCompilationState;
  21950. private _sharedData;
  21951. private _buildId;
  21952. private _buildWasSuccessful;
  21953. private _cachedWorldViewMatrix;
  21954. private _cachedWorldViewProjectionMatrix;
  21955. private _optimizers;
  21956. private _animationFrame;
  21957. /** Define the Url to load node editor script */
  21958. static EditorURL: string;
  21959. /** Define the Url to load snippets */
  21960. static SnippetUrl: string;
  21961. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  21962. static IgnoreTexturesAtLoadTime: boolean;
  21963. private BJSNODEMATERIALEDITOR;
  21964. /** Get the inspector from bundle or global */
  21965. private _getGlobalNodeMaterialEditor;
  21966. /**
  21967. * Snippet ID if the material was created from the snippet server
  21968. */
  21969. snippetId: string;
  21970. /**
  21971. * Gets or sets data used by visual editor
  21972. * @see https://nme.babylonjs.com
  21973. */
  21974. editorData: any;
  21975. /**
  21976. * 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)
  21977. */
  21978. ignoreAlpha: boolean;
  21979. /**
  21980. * Defines the maximum number of lights that can be used in the material
  21981. */
  21982. maxSimultaneousLights: number;
  21983. /**
  21984. * Observable raised when the material is built
  21985. */
  21986. onBuildObservable: Observable<NodeMaterial>;
  21987. /**
  21988. * Gets or sets the root nodes of the material vertex shader
  21989. */
  21990. _vertexOutputNodes: NodeMaterialBlock[];
  21991. /**
  21992. * Gets or sets the root nodes of the material fragment (pixel) shader
  21993. */
  21994. _fragmentOutputNodes: NodeMaterialBlock[];
  21995. /** Gets or sets options to control the node material overall behavior */
  21996. get options(): INodeMaterialOptions;
  21997. set options(options: INodeMaterialOptions);
  21998. /**
  21999. * Default configuration related to image processing available in the standard Material.
  22000. */
  22001. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22002. /**
  22003. * Gets the image processing configuration used either in this material.
  22004. */
  22005. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22006. /**
  22007. * Sets the Default image processing configuration used either in the this material.
  22008. *
  22009. * If sets to null, the scene one is in use.
  22010. */
  22011. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22012. /**
  22013. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22014. */
  22015. attachedBlocks: NodeMaterialBlock[];
  22016. /**
  22017. * Specifies the mode of the node material
  22018. * @hidden
  22019. */
  22020. _mode: NodeMaterialModes;
  22021. /**
  22022. * Gets the mode property
  22023. */
  22024. get mode(): NodeMaterialModes;
  22025. /**
  22026. * Create a new node based material
  22027. * @param name defines the material name
  22028. * @param scene defines the hosting scene
  22029. * @param options defines creation option
  22030. */
  22031. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22032. /**
  22033. * Gets the current class name of the material e.g. "NodeMaterial"
  22034. * @returns the class name
  22035. */
  22036. getClassName(): string;
  22037. /**
  22038. * Keep track of the image processing observer to allow dispose and replace.
  22039. */
  22040. private _imageProcessingObserver;
  22041. /**
  22042. * Attaches a new image processing configuration to the Standard Material.
  22043. * @param configuration
  22044. */
  22045. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22046. /**
  22047. * Get a block by its name
  22048. * @param name defines the name of the block to retrieve
  22049. * @returns the required block or null if not found
  22050. */
  22051. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22052. /**
  22053. * Get a block by its name
  22054. * @param predicate defines the predicate used to find the good candidate
  22055. * @returns the required block or null if not found
  22056. */
  22057. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22058. /**
  22059. * Get an input block by its name
  22060. * @param predicate defines the predicate used to find the good candidate
  22061. * @returns the required input block or null if not found
  22062. */
  22063. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22064. /**
  22065. * Gets the list of input blocks attached to this material
  22066. * @returns an array of InputBlocks
  22067. */
  22068. getInputBlocks(): InputBlock[];
  22069. /**
  22070. * Adds a new optimizer to the list of optimizers
  22071. * @param optimizer defines the optimizers to add
  22072. * @returns the current material
  22073. */
  22074. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22075. /**
  22076. * Remove an optimizer from the list of optimizers
  22077. * @param optimizer defines the optimizers to remove
  22078. * @returns the current material
  22079. */
  22080. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22081. /**
  22082. * Add a new block to the list of output nodes
  22083. * @param node defines the node to add
  22084. * @returns the current material
  22085. */
  22086. addOutputNode(node: NodeMaterialBlock): this;
  22087. /**
  22088. * Remove a block from the list of root nodes
  22089. * @param node defines the node to remove
  22090. * @returns the current material
  22091. */
  22092. removeOutputNode(node: NodeMaterialBlock): this;
  22093. private _addVertexOutputNode;
  22094. private _removeVertexOutputNode;
  22095. private _addFragmentOutputNode;
  22096. private _removeFragmentOutputNode;
  22097. /**
  22098. * Specifies if the material will require alpha blending
  22099. * @returns a boolean specifying if alpha blending is needed
  22100. */
  22101. needAlphaBlending(): boolean;
  22102. /**
  22103. * Specifies if this material should be rendered in alpha test mode
  22104. * @returns a boolean specifying if an alpha test is needed.
  22105. */
  22106. needAlphaTesting(): boolean;
  22107. private _initializeBlock;
  22108. private _resetDualBlocks;
  22109. /**
  22110. * Remove a block from the current node material
  22111. * @param block defines the block to remove
  22112. */
  22113. removeBlock(block: NodeMaterialBlock): void;
  22114. /**
  22115. * Build the material and generates the inner effect
  22116. * @param verbose defines if the build should log activity
  22117. */
  22118. build(verbose?: boolean): void;
  22119. /**
  22120. * Runs an otpimization phase to try to improve the shader code
  22121. */
  22122. optimize(): void;
  22123. private _prepareDefinesForAttributes;
  22124. /**
  22125. * Create a post process from the material
  22126. * @param camera The camera to apply the render pass to.
  22127. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22128. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22129. * @param engine The engine which the post process will be applied. (default: current engine)
  22130. * @param reusable If the post process can be reused on the same frame. (default: false)
  22131. * @param textureType Type of textures used when performing the post process. (default: 0)
  22132. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22133. * @returns the post process created
  22134. */
  22135. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22136. private _createEffectForParticles;
  22137. /**
  22138. * Create the effect to be used as the custom effect for a particle system
  22139. * @param particleSystem Particle system to create the effect for
  22140. * @param onCompiled defines a function to call when the effect creation is successful
  22141. * @param onError defines a function to call when the effect creation has failed
  22142. */
  22143. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22144. private _processDefines;
  22145. /**
  22146. * Get if the submesh is ready to be used and all its information available.
  22147. * Child classes can use it to update shaders
  22148. * @param mesh defines the mesh to check
  22149. * @param subMesh defines which submesh to check
  22150. * @param useInstances specifies that instances should be used
  22151. * @returns a boolean indicating that the submesh is ready or not
  22152. */
  22153. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22154. /**
  22155. * Get a string representing the shaders built by the current node graph
  22156. */
  22157. get compiledShaders(): string;
  22158. /**
  22159. * Binds the world matrix to the material
  22160. * @param world defines the world transformation matrix
  22161. */
  22162. bindOnlyWorldMatrix(world: Matrix): void;
  22163. /**
  22164. * Binds the submesh to this material by preparing the effect and shader to draw
  22165. * @param world defines the world transformation matrix
  22166. * @param mesh defines the mesh containing the submesh
  22167. * @param subMesh defines the submesh to bind the material to
  22168. */
  22169. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22170. /**
  22171. * Gets the active textures from the material
  22172. * @returns an array of textures
  22173. */
  22174. getActiveTextures(): BaseTexture[];
  22175. /**
  22176. * Gets the list of texture blocks
  22177. * @returns an array of texture blocks
  22178. */
  22179. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22180. /**
  22181. * Specifies if the material uses a texture
  22182. * @param texture defines the texture to check against the material
  22183. * @returns a boolean specifying if the material uses the texture
  22184. */
  22185. hasTexture(texture: BaseTexture): boolean;
  22186. /**
  22187. * Disposes the material
  22188. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22189. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22190. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22191. */
  22192. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22193. /** Creates the node editor window. */
  22194. private _createNodeEditor;
  22195. /**
  22196. * Launch the node material editor
  22197. * @param config Define the configuration of the editor
  22198. * @return a promise fulfilled when the node editor is visible
  22199. */
  22200. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22201. /**
  22202. * Clear the current material
  22203. */
  22204. clear(): void;
  22205. /**
  22206. * Clear the current material and set it to a default state
  22207. */
  22208. setToDefault(): void;
  22209. /**
  22210. * Clear the current material and set it to a default state for post process
  22211. */
  22212. setToDefaultPostProcess(): void;
  22213. /**
  22214. * Clear the current material and set it to a default state for particle
  22215. */
  22216. setToDefaultParticle(): void;
  22217. /**
  22218. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22219. * @param url defines the url to load from
  22220. * @returns a promise that will fullfil when the material is fully loaded
  22221. */
  22222. loadAsync(url: string): Promise<void>;
  22223. private _gatherBlocks;
  22224. /**
  22225. * Generate a string containing the code declaration required to create an equivalent of this material
  22226. * @returns a string
  22227. */
  22228. generateCode(): string;
  22229. /**
  22230. * Serializes this material in a JSON representation
  22231. * @returns the serialized material object
  22232. */
  22233. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22234. private _restoreConnections;
  22235. /**
  22236. * Clear the current graph and load a new one from a serialization object
  22237. * @param source defines the JSON representation of the material
  22238. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22239. */
  22240. loadFromSerialization(source: any, rootUrl?: string): void;
  22241. /**
  22242. * Makes a duplicate of the current material.
  22243. * @param name - name to use for the new material.
  22244. */
  22245. clone(name: string): NodeMaterial;
  22246. /**
  22247. * Creates a node material from parsed material data
  22248. * @param source defines the JSON representation of the material
  22249. * @param scene defines the hosting scene
  22250. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22251. * @returns a new node material
  22252. */
  22253. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22254. /**
  22255. * Creates a node material from a snippet saved in a remote file
  22256. * @param name defines the name of the material to create
  22257. * @param url defines the url to load from
  22258. * @param scene defines the hosting scene
  22259. * @returns a promise that will resolve to the new node material
  22260. */
  22261. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22262. /**
  22263. * Creates a node material from a snippet saved by the node material editor
  22264. * @param snippetId defines the snippet to load
  22265. * @param scene defines the hosting scene
  22266. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22267. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22268. * @returns a promise that will resolve to the new node material
  22269. */
  22270. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22271. /**
  22272. * Creates a new node material set to default basic configuration
  22273. * @param name defines the name of the material
  22274. * @param scene defines the hosting scene
  22275. * @returns a new NodeMaterial
  22276. */
  22277. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22278. }
  22279. }
  22280. declare module BABYLON {
  22281. /**
  22282. * Size options for a post process
  22283. */
  22284. export type PostProcessOptions = {
  22285. width: number;
  22286. height: number;
  22287. };
  22288. /**
  22289. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22290. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22291. */
  22292. export class PostProcess {
  22293. /** Name of the PostProcess. */
  22294. name: string;
  22295. /**
  22296. * Gets or sets the unique id of the post process
  22297. */
  22298. uniqueId: number;
  22299. /**
  22300. * Width of the texture to apply the post process on
  22301. */
  22302. width: number;
  22303. /**
  22304. * Height of the texture to apply the post process on
  22305. */
  22306. height: number;
  22307. /**
  22308. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22309. */
  22310. nodeMaterialSource: Nullable<NodeMaterial>;
  22311. /**
  22312. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22313. * @hidden
  22314. */
  22315. _outputTexture: Nullable<InternalTexture>;
  22316. /**
  22317. * Sampling mode used by the shader
  22318. * See https://doc.babylonjs.com/classes/3.1/texture
  22319. */
  22320. renderTargetSamplingMode: number;
  22321. /**
  22322. * Clear color to use when screen clearing
  22323. */
  22324. clearColor: Color4;
  22325. /**
  22326. * If the buffer needs to be cleared before applying the post process. (default: true)
  22327. * Should be set to false if shader will overwrite all previous pixels.
  22328. */
  22329. autoClear: boolean;
  22330. /**
  22331. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22332. */
  22333. alphaMode: number;
  22334. /**
  22335. * Sets the setAlphaBlendConstants of the babylon engine
  22336. */
  22337. alphaConstants: Color4;
  22338. /**
  22339. * Animations to be used for the post processing
  22340. */
  22341. animations: Animation[];
  22342. /**
  22343. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22344. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22345. */
  22346. enablePixelPerfectMode: boolean;
  22347. /**
  22348. * Force the postprocess to be applied without taking in account viewport
  22349. */
  22350. forceFullscreenViewport: boolean;
  22351. /**
  22352. * List of inspectable custom properties (used by the Inspector)
  22353. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22354. */
  22355. inspectableCustomProperties: IInspectable[];
  22356. /**
  22357. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22358. *
  22359. * | Value | Type | Description |
  22360. * | ----- | ----------------------------------- | ----------- |
  22361. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22362. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22363. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22364. *
  22365. */
  22366. scaleMode: number;
  22367. /**
  22368. * Force textures to be a power of two (default: false)
  22369. */
  22370. alwaysForcePOT: boolean;
  22371. private _samples;
  22372. /**
  22373. * Number of sample textures (default: 1)
  22374. */
  22375. get samples(): number;
  22376. set samples(n: number);
  22377. /**
  22378. * Modify the scale of the post process to be the same as the viewport (default: false)
  22379. */
  22380. adaptScaleToCurrentViewport: boolean;
  22381. private _camera;
  22382. private _scene;
  22383. private _engine;
  22384. private _options;
  22385. private _reusable;
  22386. private _textureType;
  22387. private _textureFormat;
  22388. /**
  22389. * Smart array of input and output textures for the post process.
  22390. * @hidden
  22391. */
  22392. _textures: SmartArray<InternalTexture>;
  22393. /**
  22394. * The index in _textures that corresponds to the output texture.
  22395. * @hidden
  22396. */
  22397. _currentRenderTextureInd: number;
  22398. private _effect;
  22399. private _samplers;
  22400. private _fragmentUrl;
  22401. private _vertexUrl;
  22402. private _parameters;
  22403. private _scaleRatio;
  22404. protected _indexParameters: any;
  22405. private _shareOutputWithPostProcess;
  22406. private _texelSize;
  22407. private _forcedOutputTexture;
  22408. /**
  22409. * Returns the fragment url or shader name used in the post process.
  22410. * @returns the fragment url or name in the shader store.
  22411. */
  22412. getEffectName(): string;
  22413. /**
  22414. * An event triggered when the postprocess is activated.
  22415. */
  22416. onActivateObservable: Observable<Camera>;
  22417. private _onActivateObserver;
  22418. /**
  22419. * A function that is added to the onActivateObservable
  22420. */
  22421. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22422. /**
  22423. * An event triggered when the postprocess changes its size.
  22424. */
  22425. onSizeChangedObservable: Observable<PostProcess>;
  22426. private _onSizeChangedObserver;
  22427. /**
  22428. * A function that is added to the onSizeChangedObservable
  22429. */
  22430. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22431. /**
  22432. * An event triggered when the postprocess applies its effect.
  22433. */
  22434. onApplyObservable: Observable<Effect>;
  22435. private _onApplyObserver;
  22436. /**
  22437. * A function that is added to the onApplyObservable
  22438. */
  22439. set onApply(callback: (effect: Effect) => void);
  22440. /**
  22441. * An event triggered before rendering the postprocess
  22442. */
  22443. onBeforeRenderObservable: Observable<Effect>;
  22444. private _onBeforeRenderObserver;
  22445. /**
  22446. * A function that is added to the onBeforeRenderObservable
  22447. */
  22448. set onBeforeRender(callback: (effect: Effect) => void);
  22449. /**
  22450. * An event triggered after rendering the postprocess
  22451. */
  22452. onAfterRenderObservable: Observable<Effect>;
  22453. private _onAfterRenderObserver;
  22454. /**
  22455. * A function that is added to the onAfterRenderObservable
  22456. */
  22457. set onAfterRender(callback: (efect: Effect) => void);
  22458. /**
  22459. * 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
  22460. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22461. */
  22462. get inputTexture(): InternalTexture;
  22463. set inputTexture(value: InternalTexture);
  22464. /**
  22465. * Gets the camera which post process is applied to.
  22466. * @returns The camera the post process is applied to.
  22467. */
  22468. getCamera(): Camera;
  22469. /**
  22470. * Gets the texel size of the postprocess.
  22471. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22472. */
  22473. get texelSize(): Vector2;
  22474. /**
  22475. * Creates a new instance PostProcess
  22476. * @param name The name of the PostProcess.
  22477. * @param fragmentUrl The url of the fragment shader to be used.
  22478. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22479. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22480. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22481. * @param camera The camera to apply the render pass to.
  22482. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22483. * @param engine The engine which the post process will be applied. (default: current engine)
  22484. * @param reusable If the post process can be reused on the same frame. (default: false)
  22485. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22486. * @param textureType Type of textures used when performing the post process. (default: 0)
  22487. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22488. * @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
  22489. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  22490. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22491. */
  22492. constructor(
  22493. /** Name of the PostProcess. */
  22494. 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);
  22495. /**
  22496. * Gets a string idenfifying the name of the class
  22497. * @returns "PostProcess" string
  22498. */
  22499. getClassName(): string;
  22500. /**
  22501. * Gets the engine which this post process belongs to.
  22502. * @returns The engine the post process was enabled with.
  22503. */
  22504. getEngine(): Engine;
  22505. /**
  22506. * The effect that is created when initializing the post process.
  22507. * @returns The created effect corresponding the the postprocess.
  22508. */
  22509. getEffect(): Effect;
  22510. /**
  22511. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22512. * @param postProcess The post process to share the output with.
  22513. * @returns This post process.
  22514. */
  22515. shareOutputWith(postProcess: PostProcess): PostProcess;
  22516. /**
  22517. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22518. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22519. */
  22520. useOwnOutput(): void;
  22521. /**
  22522. * Updates the effect with the current post process compile time values and recompiles the shader.
  22523. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22524. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22525. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22526. * @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
  22527. * @param onCompiled Called when the shader has been compiled.
  22528. * @param onError Called if there is an error when compiling a shader.
  22529. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  22530. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  22531. */
  22532. 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;
  22533. /**
  22534. * The post process is reusable if it can be used multiple times within one frame.
  22535. * @returns If the post process is reusable
  22536. */
  22537. isReusable(): boolean;
  22538. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  22539. markTextureDirty(): void;
  22540. /**
  22541. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  22542. * 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.
  22543. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  22544. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  22545. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  22546. * @returns The target texture that was bound to be written to.
  22547. */
  22548. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  22549. /**
  22550. * If the post process is supported.
  22551. */
  22552. get isSupported(): boolean;
  22553. /**
  22554. * The aspect ratio of the output texture.
  22555. */
  22556. get aspectRatio(): number;
  22557. /**
  22558. * Get a value indicating if the post-process is ready to be used
  22559. * @returns true if the post-process is ready (shader is compiled)
  22560. */
  22561. isReady(): boolean;
  22562. /**
  22563. * Binds all textures and uniforms to the shader, this will be run on every pass.
  22564. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  22565. */
  22566. apply(): Nullable<Effect>;
  22567. private _disposeTextures;
  22568. /**
  22569. * Disposes the post process.
  22570. * @param camera The camera to dispose the post process on.
  22571. */
  22572. dispose(camera?: Camera): void;
  22573. }
  22574. }
  22575. declare module BABYLON {
  22576. /** @hidden */
  22577. export var kernelBlurVaryingDeclaration: {
  22578. name: string;
  22579. shader: string;
  22580. };
  22581. }
  22582. declare module BABYLON {
  22583. /** @hidden */
  22584. export var kernelBlurFragment: {
  22585. name: string;
  22586. shader: string;
  22587. };
  22588. }
  22589. declare module BABYLON {
  22590. /** @hidden */
  22591. export var kernelBlurFragment2: {
  22592. name: string;
  22593. shader: string;
  22594. };
  22595. }
  22596. declare module BABYLON {
  22597. /** @hidden */
  22598. export var kernelBlurPixelShader: {
  22599. name: string;
  22600. shader: string;
  22601. };
  22602. }
  22603. declare module BABYLON {
  22604. /** @hidden */
  22605. export var kernelBlurVertex: {
  22606. name: string;
  22607. shader: string;
  22608. };
  22609. }
  22610. declare module BABYLON {
  22611. /** @hidden */
  22612. export var kernelBlurVertexShader: {
  22613. name: string;
  22614. shader: string;
  22615. };
  22616. }
  22617. declare module BABYLON {
  22618. /**
  22619. * The Blur Post Process which blurs an image based on a kernel and direction.
  22620. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  22621. */
  22622. export class BlurPostProcess extends PostProcess {
  22623. /** The direction in which to blur the image. */
  22624. direction: Vector2;
  22625. private blockCompilation;
  22626. protected _kernel: number;
  22627. protected _idealKernel: number;
  22628. protected _packedFloat: boolean;
  22629. private _staticDefines;
  22630. /**
  22631. * Sets the length in pixels of the blur sample region
  22632. */
  22633. set kernel(v: number);
  22634. /**
  22635. * Gets the length in pixels of the blur sample region
  22636. */
  22637. get kernel(): number;
  22638. /**
  22639. * Sets wether or not the blur needs to unpack/repack floats
  22640. */
  22641. set packedFloat(v: boolean);
  22642. /**
  22643. * Gets wether or not the blur is unpacking/repacking floats
  22644. */
  22645. get packedFloat(): boolean;
  22646. /**
  22647. * Creates a new instance BlurPostProcess
  22648. * @param name The name of the effect.
  22649. * @param direction The direction in which to blur the image.
  22650. * @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.
  22651. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22652. * @param camera The camera to apply the render pass to.
  22653. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22654. * @param engine The engine which the post process will be applied. (default: current engine)
  22655. * @param reusable If the post process can be reused on the same frame. (default: false)
  22656. * @param textureType Type of textures used when performing the post process. (default: 0)
  22657. * @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)
  22658. */
  22659. constructor(name: string,
  22660. /** The direction in which to blur the image. */
  22661. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  22662. /**
  22663. * Updates the effect with the current post process compile time values and recompiles the shader.
  22664. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22665. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22666. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22667. * @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
  22668. * @param onCompiled Called when the shader has been compiled.
  22669. * @param onError Called if there is an error when compiling a shader.
  22670. */
  22671. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22672. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22673. /**
  22674. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  22675. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  22676. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  22677. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  22678. * The gaps between physical kernels are compensated for in the weighting of the samples
  22679. * @param idealKernel Ideal blur kernel.
  22680. * @return Nearest best kernel.
  22681. */
  22682. protected _nearestBestKernel(idealKernel: number): number;
  22683. /**
  22684. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  22685. * @param x The point on the Gaussian distribution to sample.
  22686. * @return the value of the Gaussian function at x.
  22687. */
  22688. protected _gaussianWeight(x: number): number;
  22689. /**
  22690. * Generates a string that can be used as a floating point number in GLSL.
  22691. * @param x Value to print.
  22692. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  22693. * @return GLSL float string.
  22694. */
  22695. protected _glslFloat(x: number, decimalFigures?: number): string;
  22696. }
  22697. }
  22698. declare module BABYLON {
  22699. /**
  22700. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22701. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22702. * You can then easily use it as a reflectionTexture on a flat surface.
  22703. * In case the surface is not a plane, please consider relying on reflection probes.
  22704. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22705. */
  22706. export class MirrorTexture extends RenderTargetTexture {
  22707. private scene;
  22708. /**
  22709. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  22710. * 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.
  22711. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22712. */
  22713. mirrorPlane: Plane;
  22714. /**
  22715. * Define the blur ratio used to blur the reflection if needed.
  22716. */
  22717. set blurRatio(value: number);
  22718. get blurRatio(): number;
  22719. /**
  22720. * Define the adaptive blur kernel used to blur the reflection if needed.
  22721. * This will autocompute the closest best match for the `blurKernel`
  22722. */
  22723. set adaptiveBlurKernel(value: number);
  22724. /**
  22725. * Define the blur kernel used to blur the reflection if needed.
  22726. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22727. */
  22728. set blurKernel(value: number);
  22729. /**
  22730. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  22731. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22732. */
  22733. set blurKernelX(value: number);
  22734. get blurKernelX(): number;
  22735. /**
  22736. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  22737. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22738. */
  22739. set blurKernelY(value: number);
  22740. get blurKernelY(): number;
  22741. private _autoComputeBlurKernel;
  22742. protected _onRatioRescale(): void;
  22743. private _updateGammaSpace;
  22744. private _imageProcessingConfigChangeObserver;
  22745. private _transformMatrix;
  22746. private _mirrorMatrix;
  22747. private _savedViewMatrix;
  22748. private _blurX;
  22749. private _blurY;
  22750. private _adaptiveBlurKernel;
  22751. private _blurKernelX;
  22752. private _blurKernelY;
  22753. private _blurRatio;
  22754. /**
  22755. * Instantiates a Mirror Texture.
  22756. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22757. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22758. * You can then easily use it as a reflectionTexture on a flat surface.
  22759. * In case the surface is not a plane, please consider relying on reflection probes.
  22760. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22761. * @param name
  22762. * @param size
  22763. * @param scene
  22764. * @param generateMipMaps
  22765. * @param type
  22766. * @param samplingMode
  22767. * @param generateDepthBuffer
  22768. */
  22769. constructor(name: string, size: number | {
  22770. width: number;
  22771. height: number;
  22772. } | {
  22773. ratio: number;
  22774. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  22775. private _preparePostProcesses;
  22776. /**
  22777. * Clone the mirror texture.
  22778. * @returns the cloned texture
  22779. */
  22780. clone(): MirrorTexture;
  22781. /**
  22782. * Serialize the texture to a JSON representation you could use in Parse later on
  22783. * @returns the serialized JSON representation
  22784. */
  22785. serialize(): any;
  22786. /**
  22787. * Dispose the texture and release its associated resources.
  22788. */
  22789. dispose(): void;
  22790. }
  22791. }
  22792. declare module BABYLON {
  22793. /**
  22794. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  22795. * @see http://doc.babylonjs.com/babylon101/materials#texture
  22796. */
  22797. export class Texture extends BaseTexture {
  22798. /**
  22799. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  22800. */
  22801. static SerializeBuffers: boolean;
  22802. /** @hidden */
  22803. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  22804. /** @hidden */
  22805. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  22806. /** @hidden */
  22807. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  22808. /** nearest is mag = nearest and min = nearest and mip = linear */
  22809. static readonly NEAREST_SAMPLINGMODE: number;
  22810. /** nearest is mag = nearest and min = nearest and mip = linear */
  22811. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  22812. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22813. static readonly BILINEAR_SAMPLINGMODE: number;
  22814. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22815. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  22816. /** Trilinear is mag = linear and min = linear and mip = linear */
  22817. static readonly TRILINEAR_SAMPLINGMODE: number;
  22818. /** Trilinear is mag = linear and min = linear and mip = linear */
  22819. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  22820. /** mag = nearest and min = nearest and mip = nearest */
  22821. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  22822. /** mag = nearest and min = linear and mip = nearest */
  22823. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  22824. /** mag = nearest and min = linear and mip = linear */
  22825. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  22826. /** mag = nearest and min = linear and mip = none */
  22827. static readonly NEAREST_LINEAR: number;
  22828. /** mag = nearest and min = nearest and mip = none */
  22829. static readonly NEAREST_NEAREST: number;
  22830. /** mag = linear and min = nearest and mip = nearest */
  22831. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  22832. /** mag = linear and min = nearest and mip = linear */
  22833. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  22834. /** mag = linear and min = linear and mip = none */
  22835. static readonly LINEAR_LINEAR: number;
  22836. /** mag = linear and min = nearest and mip = none */
  22837. static readonly LINEAR_NEAREST: number;
  22838. /** Explicit coordinates mode */
  22839. static readonly EXPLICIT_MODE: number;
  22840. /** Spherical coordinates mode */
  22841. static readonly SPHERICAL_MODE: number;
  22842. /** Planar coordinates mode */
  22843. static readonly PLANAR_MODE: number;
  22844. /** Cubic coordinates mode */
  22845. static readonly CUBIC_MODE: number;
  22846. /** Projection coordinates mode */
  22847. static readonly PROJECTION_MODE: number;
  22848. /** Inverse Cubic coordinates mode */
  22849. static readonly SKYBOX_MODE: number;
  22850. /** Inverse Cubic coordinates mode */
  22851. static readonly INVCUBIC_MODE: number;
  22852. /** Equirectangular coordinates mode */
  22853. static readonly EQUIRECTANGULAR_MODE: number;
  22854. /** Equirectangular Fixed coordinates mode */
  22855. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  22856. /** Equirectangular Fixed Mirrored coordinates mode */
  22857. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  22858. /** Texture is not repeating outside of 0..1 UVs */
  22859. static readonly CLAMP_ADDRESSMODE: number;
  22860. /** Texture is repeating outside of 0..1 UVs */
  22861. static readonly WRAP_ADDRESSMODE: number;
  22862. /** Texture is repeating and mirrored */
  22863. static readonly MIRROR_ADDRESSMODE: number;
  22864. /**
  22865. * 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
  22866. */
  22867. static UseSerializedUrlIfAny: boolean;
  22868. /**
  22869. * Define the url of the texture.
  22870. */
  22871. url: Nullable<string>;
  22872. /**
  22873. * Define an offset on the texture to offset the u coordinates of the UVs
  22874. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  22875. */
  22876. uOffset: number;
  22877. /**
  22878. * Define an offset on the texture to offset the v coordinates of the UVs
  22879. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  22880. */
  22881. vOffset: number;
  22882. /**
  22883. * Define an offset on the texture to scale the u coordinates of the UVs
  22884. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  22885. */
  22886. uScale: number;
  22887. /**
  22888. * Define an offset on the texture to scale the v coordinates of the UVs
  22889. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  22890. */
  22891. vScale: number;
  22892. /**
  22893. * Define an offset on the texture to rotate around the u coordinates of the UVs
  22894. * @see http://doc.babylonjs.com/how_to/more_materials
  22895. */
  22896. uAng: number;
  22897. /**
  22898. * Define an offset on the texture to rotate around the v coordinates of the UVs
  22899. * @see http://doc.babylonjs.com/how_to/more_materials
  22900. */
  22901. vAng: number;
  22902. /**
  22903. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  22904. * @see http://doc.babylonjs.com/how_to/more_materials
  22905. */
  22906. wAng: number;
  22907. /**
  22908. * Defines the center of rotation (U)
  22909. */
  22910. uRotationCenter: number;
  22911. /**
  22912. * Defines the center of rotation (V)
  22913. */
  22914. vRotationCenter: number;
  22915. /**
  22916. * Defines the center of rotation (W)
  22917. */
  22918. wRotationCenter: number;
  22919. /**
  22920. * Are mip maps generated for this texture or not.
  22921. */
  22922. get noMipmap(): boolean;
  22923. /**
  22924. * List of inspectable custom properties (used by the Inspector)
  22925. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22926. */
  22927. inspectableCustomProperties: Nullable<IInspectable[]>;
  22928. private _noMipmap;
  22929. /** @hidden */
  22930. _invertY: boolean;
  22931. private _rowGenerationMatrix;
  22932. private _cachedTextureMatrix;
  22933. private _projectionModeMatrix;
  22934. private _t0;
  22935. private _t1;
  22936. private _t2;
  22937. private _cachedUOffset;
  22938. private _cachedVOffset;
  22939. private _cachedUScale;
  22940. private _cachedVScale;
  22941. private _cachedUAng;
  22942. private _cachedVAng;
  22943. private _cachedWAng;
  22944. private _cachedProjectionMatrixId;
  22945. private _cachedCoordinatesMode;
  22946. /** @hidden */
  22947. protected _initialSamplingMode: number;
  22948. /** @hidden */
  22949. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  22950. private _deleteBuffer;
  22951. protected _format: Nullable<number>;
  22952. private _delayedOnLoad;
  22953. private _delayedOnError;
  22954. private _mimeType?;
  22955. /**
  22956. * Observable triggered once the texture has been loaded.
  22957. */
  22958. onLoadObservable: Observable<Texture>;
  22959. protected _isBlocking: boolean;
  22960. /**
  22961. * Is the texture preventing material to render while loading.
  22962. * If false, a default texture will be used instead of the loading one during the preparation step.
  22963. */
  22964. set isBlocking(value: boolean);
  22965. get isBlocking(): boolean;
  22966. /**
  22967. * Get the current sampling mode associated with the texture.
  22968. */
  22969. get samplingMode(): number;
  22970. /**
  22971. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  22972. */
  22973. get invertY(): boolean;
  22974. /**
  22975. * Instantiates a new texture.
  22976. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  22977. * @see http://doc.babylonjs.com/babylon101/materials#texture
  22978. * @param url defines the url of the picture to load as a texture
  22979. * @param sceneOrEngine defines the scene or engine the texture will belong to
  22980. * @param noMipmap defines if the texture will require mip maps or not
  22981. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  22982. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  22983. * @param onLoad defines a callback triggered when the texture has been loaded
  22984. * @param onError defines a callback triggered when an error occurred during the loading session
  22985. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  22986. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  22987. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  22988. * @param mimeType defines an optional mime type information
  22989. */
  22990. 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);
  22991. /**
  22992. * Update the url (and optional buffer) of this texture if url was null during construction.
  22993. * @param url the url of the texture
  22994. * @param buffer the buffer of the texture (defaults to null)
  22995. * @param onLoad callback called when the texture is loaded (defaults to null)
  22996. */
  22997. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  22998. /**
  22999. * Finish the loading sequence of a texture flagged as delayed load.
  23000. * @hidden
  23001. */
  23002. delayLoad(): void;
  23003. private _prepareRowForTextureGeneration;
  23004. /**
  23005. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23006. * @returns the transform matrix of the texture.
  23007. */
  23008. getTextureMatrix(uBase?: number): Matrix;
  23009. /**
  23010. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23011. * @returns The reflection texture transform
  23012. */
  23013. getReflectionTextureMatrix(): Matrix;
  23014. /**
  23015. * Clones the texture.
  23016. * @returns the cloned texture
  23017. */
  23018. clone(): Texture;
  23019. /**
  23020. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23021. * @returns The JSON representation of the texture
  23022. */
  23023. serialize(): any;
  23024. /**
  23025. * Get the current class name of the texture useful for serialization or dynamic coding.
  23026. * @returns "Texture"
  23027. */
  23028. getClassName(): string;
  23029. /**
  23030. * Dispose the texture and release its associated resources.
  23031. */
  23032. dispose(): void;
  23033. /**
  23034. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23035. * @param parsedTexture Define the JSON representation of the texture
  23036. * @param scene Define the scene the parsed texture should be instantiated in
  23037. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23038. * @returns The parsed texture if successful
  23039. */
  23040. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23041. /**
  23042. * Creates a texture from its base 64 representation.
  23043. * @param data Define the base64 payload without the data: prefix
  23044. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23045. * @param scene Define the scene the texture should belong to
  23046. * @param noMipmap Forces the texture to not create mip map information if true
  23047. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23048. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23049. * @param onLoad define a callback triggered when the texture has been loaded
  23050. * @param onError define a callback triggered when an error occurred during the loading session
  23051. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23052. * @returns the created texture
  23053. */
  23054. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23055. /**
  23056. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23057. * @param data Define the base64 payload without the data: prefix
  23058. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23059. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23060. * @param scene Define the scene the texture should belong to
  23061. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23062. * @param noMipmap Forces the texture to not create mip map information if true
  23063. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23064. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23065. * @param onLoad define a callback triggered when the texture has been loaded
  23066. * @param onError define a callback triggered when an error occurred during the loading session
  23067. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23068. * @returns the created texture
  23069. */
  23070. 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;
  23071. }
  23072. }
  23073. declare module BABYLON {
  23074. /**
  23075. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23076. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23077. */
  23078. export class PostProcessManager {
  23079. private _scene;
  23080. private _indexBuffer;
  23081. private _vertexBuffers;
  23082. /**
  23083. * Creates a new instance PostProcess
  23084. * @param scene The scene that the post process is associated with.
  23085. */
  23086. constructor(scene: Scene);
  23087. private _prepareBuffers;
  23088. private _buildIndexBuffer;
  23089. /**
  23090. * Rebuilds the vertex buffers of the manager.
  23091. * @hidden
  23092. */
  23093. _rebuild(): void;
  23094. /**
  23095. * Prepares a frame to be run through a post process.
  23096. * @param sourceTexture The input texture to the post procesess. (default: null)
  23097. * @param postProcesses An array of post processes to be run. (default: null)
  23098. * @returns True if the post processes were able to be run.
  23099. * @hidden
  23100. */
  23101. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23102. /**
  23103. * Manually render a set of post processes to a texture.
  23104. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23105. * @param postProcesses An array of post processes to be run.
  23106. * @param targetTexture The target texture to render to.
  23107. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23108. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23109. * @param lodLevel defines which lod of the texture to render to
  23110. */
  23111. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  23112. /**
  23113. * Finalize the result of the output of the postprocesses.
  23114. * @param doNotPresent If true the result will not be displayed to the screen.
  23115. * @param targetTexture The target texture to render to.
  23116. * @param faceIndex The index of the face to bind the target texture to.
  23117. * @param postProcesses The array of post processes to render.
  23118. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23119. * @hidden
  23120. */
  23121. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23122. /**
  23123. * Disposes of the post process manager.
  23124. */
  23125. dispose(): void;
  23126. }
  23127. }
  23128. declare module BABYLON {
  23129. /**
  23130. * This Helps creating a texture that will be created from a camera in your scene.
  23131. * It is basically a dynamic texture that could be used to create special effects for instance.
  23132. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23133. */
  23134. export class RenderTargetTexture extends Texture {
  23135. isCube: boolean;
  23136. /**
  23137. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23138. */
  23139. static readonly REFRESHRATE_RENDER_ONCE: number;
  23140. /**
  23141. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23142. */
  23143. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23144. /**
  23145. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23146. * the central point of your effect and can save a lot of performances.
  23147. */
  23148. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23149. /**
  23150. * Use this predicate to dynamically define the list of mesh you want to render.
  23151. * If set, the renderList property will be overwritten.
  23152. */
  23153. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23154. private _renderList;
  23155. /**
  23156. * Use this list to define the list of mesh you want to render.
  23157. */
  23158. get renderList(): Nullable<Array<AbstractMesh>>;
  23159. set renderList(value: Nullable<Array<AbstractMesh>>);
  23160. /**
  23161. * Use this function to overload the renderList array at rendering time.
  23162. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  23163. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  23164. * the cube (if the RTT is a cube, else layerOrFace=0).
  23165. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  23166. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  23167. * hold dummy elements!
  23168. */
  23169. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  23170. private _hookArray;
  23171. /**
  23172. * Define if particles should be rendered in your texture.
  23173. */
  23174. renderParticles: boolean;
  23175. /**
  23176. * Define if sprites should be rendered in your texture.
  23177. */
  23178. renderSprites: boolean;
  23179. /**
  23180. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  23181. */
  23182. coordinatesMode: number;
  23183. /**
  23184. * Define the camera used to render the texture.
  23185. */
  23186. activeCamera: Nullable<Camera>;
  23187. /**
  23188. * Override the mesh isReady function with your own one.
  23189. */
  23190. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  23191. /**
  23192. * Override the render function of the texture with your own one.
  23193. */
  23194. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  23195. /**
  23196. * Define if camera post processes should be use while rendering the texture.
  23197. */
  23198. useCameraPostProcesses: boolean;
  23199. /**
  23200. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  23201. */
  23202. ignoreCameraViewport: boolean;
  23203. private _postProcessManager;
  23204. private _postProcesses;
  23205. private _resizeObserver;
  23206. /**
  23207. * An event triggered when the texture is unbind.
  23208. */
  23209. onBeforeBindObservable: Observable<RenderTargetTexture>;
  23210. /**
  23211. * An event triggered when the texture is unbind.
  23212. */
  23213. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  23214. private _onAfterUnbindObserver;
  23215. /**
  23216. * Set a after unbind callback in the texture.
  23217. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  23218. */
  23219. set onAfterUnbind(callback: () => void);
  23220. /**
  23221. * An event triggered before rendering the texture
  23222. */
  23223. onBeforeRenderObservable: Observable<number>;
  23224. private _onBeforeRenderObserver;
  23225. /**
  23226. * Set a before render callback in the texture.
  23227. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  23228. */
  23229. set onBeforeRender(callback: (faceIndex: number) => void);
  23230. /**
  23231. * An event triggered after rendering the texture
  23232. */
  23233. onAfterRenderObservable: Observable<number>;
  23234. private _onAfterRenderObserver;
  23235. /**
  23236. * Set a after render callback in the texture.
  23237. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  23238. */
  23239. set onAfterRender(callback: (faceIndex: number) => void);
  23240. /**
  23241. * An event triggered after the texture clear
  23242. */
  23243. onClearObservable: Observable<Engine>;
  23244. private _onClearObserver;
  23245. /**
  23246. * Set a clear callback in the texture.
  23247. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  23248. */
  23249. set onClear(callback: (Engine: Engine) => void);
  23250. /**
  23251. * An event triggered when the texture is resized.
  23252. */
  23253. onResizeObservable: Observable<RenderTargetTexture>;
  23254. /**
  23255. * Define the clear color of the Render Target if it should be different from the scene.
  23256. */
  23257. clearColor: Color4;
  23258. protected _size: number | {
  23259. width: number;
  23260. height: number;
  23261. layers?: number;
  23262. };
  23263. protected _initialSizeParameter: number | {
  23264. width: number;
  23265. height: number;
  23266. } | {
  23267. ratio: number;
  23268. };
  23269. protected _sizeRatio: Nullable<number>;
  23270. /** @hidden */
  23271. _generateMipMaps: boolean;
  23272. protected _renderingManager: RenderingManager;
  23273. /** @hidden */
  23274. _waitingRenderList: string[];
  23275. protected _doNotChangeAspectRatio: boolean;
  23276. protected _currentRefreshId: number;
  23277. protected _refreshRate: number;
  23278. protected _textureMatrix: Matrix;
  23279. protected _samples: number;
  23280. protected _renderTargetOptions: RenderTargetCreationOptions;
  23281. /**
  23282. * Gets render target creation options that were used.
  23283. */
  23284. get renderTargetOptions(): RenderTargetCreationOptions;
  23285. protected _onRatioRescale(): void;
  23286. /**
  23287. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  23288. * It must define where the camera used to render the texture is set
  23289. */
  23290. boundingBoxPosition: Vector3;
  23291. private _boundingBoxSize;
  23292. /**
  23293. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  23294. * When defined, the cubemap will switch to local mode
  23295. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  23296. * @example https://www.babylonjs-playground.com/#RNASML
  23297. */
  23298. set boundingBoxSize(value: Vector3);
  23299. get boundingBoxSize(): Vector3;
  23300. /**
  23301. * In case the RTT has been created with a depth texture, get the associated
  23302. * depth texture.
  23303. * Otherwise, return null.
  23304. */
  23305. get depthStencilTexture(): Nullable<InternalTexture>;
  23306. /**
  23307. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  23308. * or used a shadow, depth texture...
  23309. * @param name The friendly name of the texture
  23310. * @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)
  23311. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  23312. * @param generateMipMaps True if mip maps need to be generated after render.
  23313. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  23314. * @param type The type of the buffer in the RTT (int, half float, float...)
  23315. * @param isCube True if a cube texture needs to be created
  23316. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  23317. * @param generateDepthBuffer True to generate a depth buffer
  23318. * @param generateStencilBuffer True to generate a stencil buffer
  23319. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  23320. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  23321. * @param delayAllocation if the texture allocation should be delayed (default: false)
  23322. */
  23323. constructor(name: string, size: number | {
  23324. width: number;
  23325. height: number;
  23326. layers?: number;
  23327. } | {
  23328. ratio: number;
  23329. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  23330. /**
  23331. * Creates a depth stencil texture.
  23332. * This is only available in WebGL 2 or with the depth texture extension available.
  23333. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  23334. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  23335. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  23336. */
  23337. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  23338. private _processSizeParameter;
  23339. /**
  23340. * Define the number of samples to use in case of MSAA.
  23341. * It defaults to one meaning no MSAA has been enabled.
  23342. */
  23343. get samples(): number;
  23344. set samples(value: number);
  23345. /**
  23346. * Resets the refresh counter of the texture and start bak from scratch.
  23347. * Could be useful to regenerate the texture if it is setup to render only once.
  23348. */
  23349. resetRefreshCounter(): void;
  23350. /**
  23351. * Define the refresh rate of the texture or the rendering frequency.
  23352. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  23353. */
  23354. get refreshRate(): number;
  23355. set refreshRate(value: number);
  23356. /**
  23357. * Adds a post process to the render target rendering passes.
  23358. * @param postProcess define the post process to add
  23359. */
  23360. addPostProcess(postProcess: PostProcess): void;
  23361. /**
  23362. * Clear all the post processes attached to the render target
  23363. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  23364. */
  23365. clearPostProcesses(dispose?: boolean): void;
  23366. /**
  23367. * Remove one of the post process from the list of attached post processes to the texture
  23368. * @param postProcess define the post process to remove from the list
  23369. */
  23370. removePostProcess(postProcess: PostProcess): void;
  23371. /** @hidden */
  23372. _shouldRender(): boolean;
  23373. /**
  23374. * Gets the actual render size of the texture.
  23375. * @returns the width of the render size
  23376. */
  23377. getRenderSize(): number;
  23378. /**
  23379. * Gets the actual render width of the texture.
  23380. * @returns the width of the render size
  23381. */
  23382. getRenderWidth(): number;
  23383. /**
  23384. * Gets the actual render height of the texture.
  23385. * @returns the height of the render size
  23386. */
  23387. getRenderHeight(): number;
  23388. /**
  23389. * Gets the actual number of layers of the texture.
  23390. * @returns the number of layers
  23391. */
  23392. getRenderLayers(): number;
  23393. /**
  23394. * Get if the texture can be rescaled or not.
  23395. */
  23396. get canRescale(): boolean;
  23397. /**
  23398. * Resize the texture using a ratio.
  23399. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  23400. */
  23401. scale(ratio: number): void;
  23402. /**
  23403. * Get the texture reflection matrix used to rotate/transform the reflection.
  23404. * @returns the reflection matrix
  23405. */
  23406. getReflectionTextureMatrix(): Matrix;
  23407. /**
  23408. * Resize the texture to a new desired size.
  23409. * Be carrefull as it will recreate all the data in the new texture.
  23410. * @param size Define the new size. It can be:
  23411. * - a number for squared texture,
  23412. * - an object containing { width: number, height: number }
  23413. * - or an object containing a ratio { ratio: number }
  23414. */
  23415. resize(size: number | {
  23416. width: number;
  23417. height: number;
  23418. } | {
  23419. ratio: number;
  23420. }): void;
  23421. private _defaultRenderListPrepared;
  23422. /**
  23423. * Renders all the objects from the render list into the texture.
  23424. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  23425. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  23426. */
  23427. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  23428. private _bestReflectionRenderTargetDimension;
  23429. private _prepareRenderingManager;
  23430. /**
  23431. * @hidden
  23432. * @param faceIndex face index to bind to if this is a cubetexture
  23433. * @param layer defines the index of the texture to bind in the array
  23434. */
  23435. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  23436. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23437. private renderToTarget;
  23438. /**
  23439. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  23440. * This allowed control for front to back rendering or reversly depending of the special needs.
  23441. *
  23442. * @param renderingGroupId The rendering group id corresponding to its index
  23443. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  23444. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  23445. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  23446. */
  23447. 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;
  23448. /**
  23449. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  23450. *
  23451. * @param renderingGroupId The rendering group id corresponding to its index
  23452. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23453. */
  23454. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  23455. /**
  23456. * Clones the texture.
  23457. * @returns the cloned texture
  23458. */
  23459. clone(): RenderTargetTexture;
  23460. /**
  23461. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23462. * @returns The JSON representation of the texture
  23463. */
  23464. serialize(): any;
  23465. /**
  23466. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  23467. */
  23468. disposeFramebufferObjects(): void;
  23469. /**
  23470. * Dispose the texture and release its associated resources.
  23471. */
  23472. dispose(): void;
  23473. /** @hidden */
  23474. _rebuild(): void;
  23475. /**
  23476. * Clear the info related to rendering groups preventing retention point in material dispose.
  23477. */
  23478. freeRenderingGroups(): void;
  23479. /**
  23480. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  23481. * @returns the view count
  23482. */
  23483. getViewCount(): number;
  23484. }
  23485. }
  23486. declare module BABYLON {
  23487. /**
  23488. * Class used to manipulate GUIDs
  23489. */
  23490. export class GUID {
  23491. /**
  23492. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23493. * Be aware Math.random() could cause collisions, but:
  23494. * "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"
  23495. * @returns a pseudo random id
  23496. */
  23497. static RandomId(): string;
  23498. }
  23499. }
  23500. declare module BABYLON {
  23501. /**
  23502. * Options to be used when creating a shadow depth material
  23503. */
  23504. export interface IIOptionShadowDepthMaterial {
  23505. /** Variables in the vertex shader code that need to have their names remapped.
  23506. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  23507. * "var_name" should be either: worldPos or vNormalW
  23508. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  23509. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  23510. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  23511. */
  23512. remappedVariables?: string[];
  23513. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  23514. standalone?: boolean;
  23515. }
  23516. /**
  23517. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  23518. */
  23519. export class ShadowDepthWrapper {
  23520. private _scene;
  23521. private _options?;
  23522. private _baseMaterial;
  23523. private _onEffectCreatedObserver;
  23524. private _subMeshToEffect;
  23525. private _subMeshToDepthEffect;
  23526. private _meshes;
  23527. /** @hidden */
  23528. _matriceNames: any;
  23529. /** Gets the standalone status of the wrapper */
  23530. get standalone(): boolean;
  23531. /** Gets the base material the wrapper is built upon */
  23532. get baseMaterial(): Material;
  23533. /**
  23534. * Instantiate a new shadow depth wrapper.
  23535. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  23536. * generate the shadow depth map. For more information, please refer to the documentation:
  23537. * https://doc.babylonjs.com/babylon101/shadows
  23538. * @param baseMaterial Material to wrap
  23539. * @param scene Define the scene the material belongs to
  23540. * @param options Options used to create the wrapper
  23541. */
  23542. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  23543. /**
  23544. * Gets the effect to use to generate the depth map
  23545. * @param subMesh subMesh to get the effect for
  23546. * @param shadowGenerator shadow generator to get the effect for
  23547. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  23548. */
  23549. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  23550. /**
  23551. * Specifies that the submesh is ready to be used for depth rendering
  23552. * @param subMesh submesh to check
  23553. * @param defines the list of defines to take into account when checking the effect
  23554. * @param shadowGenerator combined with subMesh, it defines the effect to check
  23555. * @param useInstances specifies that instances should be used
  23556. * @returns a boolean indicating that the submesh is ready or not
  23557. */
  23558. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  23559. /**
  23560. * Disposes the resources
  23561. */
  23562. dispose(): void;
  23563. private _makeEffect;
  23564. }
  23565. }
  23566. declare module BABYLON {
  23567. /**
  23568. * Options for compiling materials.
  23569. */
  23570. export interface IMaterialCompilationOptions {
  23571. /**
  23572. * Defines whether clip planes are enabled.
  23573. */
  23574. clipPlane: boolean;
  23575. /**
  23576. * Defines whether instances are enabled.
  23577. */
  23578. useInstances: boolean;
  23579. }
  23580. /**
  23581. * Base class for the main features of a material in Babylon.js
  23582. */
  23583. export class Material implements IAnimatable {
  23584. /**
  23585. * Returns the triangle fill mode
  23586. */
  23587. static readonly TriangleFillMode: number;
  23588. /**
  23589. * Returns the wireframe mode
  23590. */
  23591. static readonly WireFrameFillMode: number;
  23592. /**
  23593. * Returns the point fill mode
  23594. */
  23595. static readonly PointFillMode: number;
  23596. /**
  23597. * Returns the point list draw mode
  23598. */
  23599. static readonly PointListDrawMode: number;
  23600. /**
  23601. * Returns the line list draw mode
  23602. */
  23603. static readonly LineListDrawMode: number;
  23604. /**
  23605. * Returns the line loop draw mode
  23606. */
  23607. static readonly LineLoopDrawMode: number;
  23608. /**
  23609. * Returns the line strip draw mode
  23610. */
  23611. static readonly LineStripDrawMode: number;
  23612. /**
  23613. * Returns the triangle strip draw mode
  23614. */
  23615. static readonly TriangleStripDrawMode: number;
  23616. /**
  23617. * Returns the triangle fan draw mode
  23618. */
  23619. static readonly TriangleFanDrawMode: number;
  23620. /**
  23621. * Stores the clock-wise side orientation
  23622. */
  23623. static readonly ClockWiseSideOrientation: number;
  23624. /**
  23625. * Stores the counter clock-wise side orientation
  23626. */
  23627. static readonly CounterClockWiseSideOrientation: number;
  23628. /**
  23629. * The dirty texture flag value
  23630. */
  23631. static readonly TextureDirtyFlag: number;
  23632. /**
  23633. * The dirty light flag value
  23634. */
  23635. static readonly LightDirtyFlag: number;
  23636. /**
  23637. * The dirty fresnel flag value
  23638. */
  23639. static readonly FresnelDirtyFlag: number;
  23640. /**
  23641. * The dirty attribute flag value
  23642. */
  23643. static readonly AttributesDirtyFlag: number;
  23644. /**
  23645. * The dirty misc flag value
  23646. */
  23647. static readonly MiscDirtyFlag: number;
  23648. /**
  23649. * The all dirty flag value
  23650. */
  23651. static readonly AllDirtyFlag: number;
  23652. /**
  23653. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  23654. */
  23655. static readonly MATERIAL_OPAQUE: number;
  23656. /**
  23657. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  23658. */
  23659. static readonly MATERIAL_ALPHATEST: number;
  23660. /**
  23661. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23662. */
  23663. static readonly MATERIAL_ALPHABLEND: number;
  23664. /**
  23665. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23666. * They are also discarded below the alpha cutoff threshold to improve performances.
  23667. */
  23668. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  23669. /**
  23670. * Custom callback helping to override the default shader used in the material.
  23671. */
  23672. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[]) => string;
  23673. /**
  23674. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  23675. */
  23676. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  23677. /**
  23678. * The ID of the material
  23679. */
  23680. id: string;
  23681. /**
  23682. * Gets or sets the unique id of the material
  23683. */
  23684. uniqueId: number;
  23685. /**
  23686. * The name of the material
  23687. */
  23688. name: string;
  23689. /**
  23690. * Gets or sets user defined metadata
  23691. */
  23692. metadata: any;
  23693. /**
  23694. * For internal use only. Please do not use.
  23695. */
  23696. reservedDataStore: any;
  23697. /**
  23698. * Specifies if the ready state should be checked on each call
  23699. */
  23700. checkReadyOnEveryCall: boolean;
  23701. /**
  23702. * Specifies if the ready state should be checked once
  23703. */
  23704. checkReadyOnlyOnce: boolean;
  23705. /**
  23706. * The state of the material
  23707. */
  23708. state: string;
  23709. /**
  23710. * The alpha value of the material
  23711. */
  23712. protected _alpha: number;
  23713. /**
  23714. * List of inspectable custom properties (used by the Inspector)
  23715. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23716. */
  23717. inspectableCustomProperties: IInspectable[];
  23718. /**
  23719. * Sets the alpha value of the material
  23720. */
  23721. set alpha(value: number);
  23722. /**
  23723. * Gets the alpha value of the material
  23724. */
  23725. get alpha(): number;
  23726. /**
  23727. * Specifies if back face culling is enabled
  23728. */
  23729. protected _backFaceCulling: boolean;
  23730. /**
  23731. * Sets the back-face culling state
  23732. */
  23733. set backFaceCulling(value: boolean);
  23734. /**
  23735. * Gets the back-face culling state
  23736. */
  23737. get backFaceCulling(): boolean;
  23738. /**
  23739. * Stores the value for side orientation
  23740. */
  23741. sideOrientation: number;
  23742. /**
  23743. * Callback triggered when the material is compiled
  23744. */
  23745. onCompiled: Nullable<(effect: Effect) => void>;
  23746. /**
  23747. * Callback triggered when an error occurs
  23748. */
  23749. onError: Nullable<(effect: Effect, errors: string) => void>;
  23750. /**
  23751. * Callback triggered to get the render target textures
  23752. */
  23753. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  23754. /**
  23755. * Gets a boolean indicating that current material needs to register RTT
  23756. */
  23757. get hasRenderTargetTextures(): boolean;
  23758. /**
  23759. * Specifies if the material should be serialized
  23760. */
  23761. doNotSerialize: boolean;
  23762. /**
  23763. * @hidden
  23764. */
  23765. _storeEffectOnSubMeshes: boolean;
  23766. /**
  23767. * Stores the animations for the material
  23768. */
  23769. animations: Nullable<Array<Animation>>;
  23770. /**
  23771. * An event triggered when the material is disposed
  23772. */
  23773. onDisposeObservable: Observable<Material>;
  23774. /**
  23775. * An observer which watches for dispose events
  23776. */
  23777. private _onDisposeObserver;
  23778. private _onUnBindObservable;
  23779. /**
  23780. * Called during a dispose event
  23781. */
  23782. set onDispose(callback: () => void);
  23783. private _onBindObservable;
  23784. /**
  23785. * An event triggered when the material is bound
  23786. */
  23787. get onBindObservable(): Observable<AbstractMesh>;
  23788. /**
  23789. * An observer which watches for bind events
  23790. */
  23791. private _onBindObserver;
  23792. /**
  23793. * Called during a bind event
  23794. */
  23795. set onBind(callback: (Mesh: AbstractMesh) => void);
  23796. /**
  23797. * An event triggered when the material is unbound
  23798. */
  23799. get onUnBindObservable(): Observable<Material>;
  23800. protected _onEffectCreatedObservable: Nullable<Observable<{
  23801. effect: Effect;
  23802. subMesh: Nullable<SubMesh>;
  23803. }>>;
  23804. /**
  23805. * An event triggered when the effect is (re)created
  23806. */
  23807. get onEffectCreatedObservable(): Observable<{
  23808. effect: Effect;
  23809. subMesh: Nullable<SubMesh>;
  23810. }>;
  23811. /**
  23812. * Stores the value of the alpha mode
  23813. */
  23814. private _alphaMode;
  23815. /**
  23816. * Sets the value of the alpha mode.
  23817. *
  23818. * | Value | Type | Description |
  23819. * | --- | --- | --- |
  23820. * | 0 | ALPHA_DISABLE | |
  23821. * | 1 | ALPHA_ADD | |
  23822. * | 2 | ALPHA_COMBINE | |
  23823. * | 3 | ALPHA_SUBTRACT | |
  23824. * | 4 | ALPHA_MULTIPLY | |
  23825. * | 5 | ALPHA_MAXIMIZED | |
  23826. * | 6 | ALPHA_ONEONE | |
  23827. * | 7 | ALPHA_PREMULTIPLIED | |
  23828. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  23829. * | 9 | ALPHA_INTERPOLATE | |
  23830. * | 10 | ALPHA_SCREENMODE | |
  23831. *
  23832. */
  23833. set alphaMode(value: number);
  23834. /**
  23835. * Gets the value of the alpha mode
  23836. */
  23837. get alphaMode(): number;
  23838. /**
  23839. * Stores the state of the need depth pre-pass value
  23840. */
  23841. private _needDepthPrePass;
  23842. /**
  23843. * Sets the need depth pre-pass value
  23844. */
  23845. set needDepthPrePass(value: boolean);
  23846. /**
  23847. * Gets the depth pre-pass value
  23848. */
  23849. get needDepthPrePass(): boolean;
  23850. /**
  23851. * Specifies if depth writing should be disabled
  23852. */
  23853. disableDepthWrite: boolean;
  23854. /**
  23855. * Specifies if color writing should be disabled
  23856. */
  23857. disableColorWrite: boolean;
  23858. /**
  23859. * Specifies if depth writing should be forced
  23860. */
  23861. forceDepthWrite: boolean;
  23862. /**
  23863. * Specifies the depth function that should be used. 0 means the default engine function
  23864. */
  23865. depthFunction: number;
  23866. /**
  23867. * Specifies if there should be a separate pass for culling
  23868. */
  23869. separateCullingPass: boolean;
  23870. /**
  23871. * Stores the state specifing if fog should be enabled
  23872. */
  23873. private _fogEnabled;
  23874. /**
  23875. * Sets the state for enabling fog
  23876. */
  23877. set fogEnabled(value: boolean);
  23878. /**
  23879. * Gets the value of the fog enabled state
  23880. */
  23881. get fogEnabled(): boolean;
  23882. /**
  23883. * Stores the size of points
  23884. */
  23885. pointSize: number;
  23886. /**
  23887. * Stores the z offset value
  23888. */
  23889. zOffset: number;
  23890. get wireframe(): boolean;
  23891. /**
  23892. * Sets the state of wireframe mode
  23893. */
  23894. set wireframe(value: boolean);
  23895. /**
  23896. * Gets the value specifying if point clouds are enabled
  23897. */
  23898. get pointsCloud(): boolean;
  23899. /**
  23900. * Sets the state of point cloud mode
  23901. */
  23902. set pointsCloud(value: boolean);
  23903. /**
  23904. * Gets the material fill mode
  23905. */
  23906. get fillMode(): number;
  23907. /**
  23908. * Sets the material fill mode
  23909. */
  23910. set fillMode(value: number);
  23911. /**
  23912. * @hidden
  23913. * Stores the effects for the material
  23914. */
  23915. _effect: Nullable<Effect>;
  23916. /**
  23917. * Specifies if uniform buffers should be used
  23918. */
  23919. private _useUBO;
  23920. /**
  23921. * Stores a reference to the scene
  23922. */
  23923. private _scene;
  23924. /**
  23925. * Stores the fill mode state
  23926. */
  23927. private _fillMode;
  23928. /**
  23929. * Specifies if the depth write state should be cached
  23930. */
  23931. private _cachedDepthWriteState;
  23932. /**
  23933. * Specifies if the color write state should be cached
  23934. */
  23935. private _cachedColorWriteState;
  23936. /**
  23937. * Specifies if the depth function state should be cached
  23938. */
  23939. private _cachedDepthFunctionState;
  23940. /**
  23941. * Stores the uniform buffer
  23942. */
  23943. protected _uniformBuffer: UniformBuffer;
  23944. /** @hidden */
  23945. _indexInSceneMaterialArray: number;
  23946. /** @hidden */
  23947. meshMap: Nullable<{
  23948. [id: string]: AbstractMesh | undefined;
  23949. }>;
  23950. /**
  23951. * Creates a material instance
  23952. * @param name defines the name of the material
  23953. * @param scene defines the scene to reference
  23954. * @param doNotAdd specifies if the material should be added to the scene
  23955. */
  23956. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  23957. /**
  23958. * Returns a string representation of the current material
  23959. * @param fullDetails defines a boolean indicating which levels of logging is desired
  23960. * @returns a string with material information
  23961. */
  23962. toString(fullDetails?: boolean): string;
  23963. /**
  23964. * Gets the class name of the material
  23965. * @returns a string with the class name of the material
  23966. */
  23967. getClassName(): string;
  23968. /**
  23969. * Specifies if updates for the material been locked
  23970. */
  23971. get isFrozen(): boolean;
  23972. /**
  23973. * Locks updates for the material
  23974. */
  23975. freeze(): void;
  23976. /**
  23977. * Unlocks updates for the material
  23978. */
  23979. unfreeze(): void;
  23980. /**
  23981. * Specifies if the material is ready to be used
  23982. * @param mesh defines the mesh to check
  23983. * @param useInstances specifies if instances should be used
  23984. * @returns a boolean indicating if the material is ready to be used
  23985. */
  23986. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  23987. /**
  23988. * Specifies that the submesh is ready to be used
  23989. * @param mesh defines the mesh to check
  23990. * @param subMesh defines which submesh to check
  23991. * @param useInstances specifies that instances should be used
  23992. * @returns a boolean indicating that the submesh is ready or not
  23993. */
  23994. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  23995. /**
  23996. * Returns the material effect
  23997. * @returns the effect associated with the material
  23998. */
  23999. getEffect(): Nullable<Effect>;
  24000. /**
  24001. * Returns the current scene
  24002. * @returns a Scene
  24003. */
  24004. getScene(): Scene;
  24005. /**
  24006. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24007. */
  24008. protected _forceAlphaTest: boolean;
  24009. /**
  24010. * The transparency mode of the material.
  24011. */
  24012. protected _transparencyMode: Nullable<number>;
  24013. /**
  24014. * Gets the current transparency mode.
  24015. */
  24016. get transparencyMode(): Nullable<number>;
  24017. /**
  24018. * Sets the transparency mode of the material.
  24019. *
  24020. * | Value | Type | Description |
  24021. * | ----- | ----------------------------------- | ----------- |
  24022. * | 0 | OPAQUE | |
  24023. * | 1 | ALPHATEST | |
  24024. * | 2 | ALPHABLEND | |
  24025. * | 3 | ALPHATESTANDBLEND | |
  24026. *
  24027. */
  24028. set transparencyMode(value: Nullable<number>);
  24029. /**
  24030. * Returns true if alpha blending should be disabled.
  24031. */
  24032. protected get _disableAlphaBlending(): boolean;
  24033. /**
  24034. * Specifies whether or not this material should be rendered in alpha blend mode.
  24035. * @returns a boolean specifying if alpha blending is needed
  24036. */
  24037. needAlphaBlending(): boolean;
  24038. /**
  24039. * Specifies if the mesh will require alpha blending
  24040. * @param mesh defines the mesh to check
  24041. * @returns a boolean specifying if alpha blending is needed for the mesh
  24042. */
  24043. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  24044. /**
  24045. * Specifies whether or not this material should be rendered in alpha test mode.
  24046. * @returns a boolean specifying if an alpha test is needed.
  24047. */
  24048. needAlphaTesting(): boolean;
  24049. /**
  24050. * Specifies if material alpha testing should be turned on for the mesh
  24051. * @param mesh defines the mesh to check
  24052. */
  24053. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  24054. /**
  24055. * Gets the texture used for the alpha test
  24056. * @returns the texture to use for alpha testing
  24057. */
  24058. getAlphaTestTexture(): Nullable<BaseTexture>;
  24059. /**
  24060. * Marks the material to indicate that it needs to be re-calculated
  24061. */
  24062. markDirty(): void;
  24063. /** @hidden */
  24064. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  24065. /**
  24066. * Binds the material to the mesh
  24067. * @param world defines the world transformation matrix
  24068. * @param mesh defines the mesh to bind the material to
  24069. */
  24070. bind(world: Matrix, mesh?: Mesh): void;
  24071. /**
  24072. * Binds the submesh to the material
  24073. * @param world defines the world transformation matrix
  24074. * @param mesh defines the mesh containing the submesh
  24075. * @param subMesh defines the submesh to bind the material to
  24076. */
  24077. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24078. /**
  24079. * Binds the world matrix to the material
  24080. * @param world defines the world transformation matrix
  24081. */
  24082. bindOnlyWorldMatrix(world: Matrix): void;
  24083. /**
  24084. * Binds the scene's uniform buffer to the effect.
  24085. * @param effect defines the effect to bind to the scene uniform buffer
  24086. * @param sceneUbo defines the uniform buffer storing scene data
  24087. */
  24088. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  24089. /**
  24090. * Binds the view matrix to the effect
  24091. * @param effect defines the effect to bind the view matrix to
  24092. */
  24093. bindView(effect: Effect): void;
  24094. /**
  24095. * Binds the view projection matrix to the effect
  24096. * @param effect defines the effect to bind the view projection matrix to
  24097. */
  24098. bindViewProjection(effect: Effect): void;
  24099. /**
  24100. * Processes to execute after binding the material to a mesh
  24101. * @param mesh defines the rendered mesh
  24102. */
  24103. protected _afterBind(mesh?: Mesh): void;
  24104. /**
  24105. * Unbinds the material from the mesh
  24106. */
  24107. unbind(): void;
  24108. /**
  24109. * Gets the active textures from the material
  24110. * @returns an array of textures
  24111. */
  24112. getActiveTextures(): BaseTexture[];
  24113. /**
  24114. * Specifies if the material uses a texture
  24115. * @param texture defines the texture to check against the material
  24116. * @returns a boolean specifying if the material uses the texture
  24117. */
  24118. hasTexture(texture: BaseTexture): boolean;
  24119. /**
  24120. * Makes a duplicate of the material, and gives it a new name
  24121. * @param name defines the new name for the duplicated material
  24122. * @returns the cloned material
  24123. */
  24124. clone(name: string): Nullable<Material>;
  24125. /**
  24126. * Gets the meshes bound to the material
  24127. * @returns an array of meshes bound to the material
  24128. */
  24129. getBindedMeshes(): AbstractMesh[];
  24130. /**
  24131. * Force shader compilation
  24132. * @param mesh defines the mesh associated with this material
  24133. * @param onCompiled defines a function to execute once the material is compiled
  24134. * @param options defines the options to configure the compilation
  24135. * @param onError defines a function to execute if the material fails compiling
  24136. */
  24137. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  24138. /**
  24139. * Force shader compilation
  24140. * @param mesh defines the mesh that will use this material
  24141. * @param options defines additional options for compiling the shaders
  24142. * @returns a promise that resolves when the compilation completes
  24143. */
  24144. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  24145. private static readonly _AllDirtyCallBack;
  24146. private static readonly _ImageProcessingDirtyCallBack;
  24147. private static readonly _TextureDirtyCallBack;
  24148. private static readonly _FresnelDirtyCallBack;
  24149. private static readonly _MiscDirtyCallBack;
  24150. private static readonly _LightsDirtyCallBack;
  24151. private static readonly _AttributeDirtyCallBack;
  24152. private static _FresnelAndMiscDirtyCallBack;
  24153. private static _TextureAndMiscDirtyCallBack;
  24154. private static readonly _DirtyCallbackArray;
  24155. private static readonly _RunDirtyCallBacks;
  24156. /**
  24157. * Marks a define in the material to indicate that it needs to be re-computed
  24158. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  24159. */
  24160. markAsDirty(flag: number): void;
  24161. /**
  24162. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  24163. * @param func defines a function which checks material defines against the submeshes
  24164. */
  24165. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  24166. /**
  24167. * Indicates that we need to re-calculated for all submeshes
  24168. */
  24169. protected _markAllSubMeshesAsAllDirty(): void;
  24170. /**
  24171. * Indicates that image processing needs to be re-calculated for all submeshes
  24172. */
  24173. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  24174. /**
  24175. * Indicates that textures need to be re-calculated for all submeshes
  24176. */
  24177. protected _markAllSubMeshesAsTexturesDirty(): void;
  24178. /**
  24179. * Indicates that fresnel needs to be re-calculated for all submeshes
  24180. */
  24181. protected _markAllSubMeshesAsFresnelDirty(): void;
  24182. /**
  24183. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  24184. */
  24185. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  24186. /**
  24187. * Indicates that lights need to be re-calculated for all submeshes
  24188. */
  24189. protected _markAllSubMeshesAsLightsDirty(): void;
  24190. /**
  24191. * Indicates that attributes need to be re-calculated for all submeshes
  24192. */
  24193. protected _markAllSubMeshesAsAttributesDirty(): void;
  24194. /**
  24195. * Indicates that misc needs to be re-calculated for all submeshes
  24196. */
  24197. protected _markAllSubMeshesAsMiscDirty(): void;
  24198. /**
  24199. * Indicates that textures and misc need to be re-calculated for all submeshes
  24200. */
  24201. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  24202. /**
  24203. * Disposes the material
  24204. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  24205. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  24206. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  24207. */
  24208. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  24209. /** @hidden */
  24210. private releaseVertexArrayObject;
  24211. /**
  24212. * Serializes this material
  24213. * @returns the serialized material object
  24214. */
  24215. serialize(): any;
  24216. /**
  24217. * Creates a material from parsed material data
  24218. * @param parsedMaterial defines parsed material data
  24219. * @param scene defines the hosting scene
  24220. * @param rootUrl defines the root URL to use to load textures
  24221. * @returns a new material
  24222. */
  24223. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  24224. }
  24225. }
  24226. declare module BABYLON {
  24227. /**
  24228. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24229. * separate meshes. This can be use to improve performances.
  24230. * @see http://doc.babylonjs.com/how_to/multi_materials
  24231. */
  24232. export class MultiMaterial extends Material {
  24233. private _subMaterials;
  24234. /**
  24235. * Gets or Sets the list of Materials used within the multi material.
  24236. * They need to be ordered according to the submeshes order in the associated mesh
  24237. */
  24238. get subMaterials(): Nullable<Material>[];
  24239. set subMaterials(value: Nullable<Material>[]);
  24240. /**
  24241. * Function used to align with Node.getChildren()
  24242. * @returns the list of Materials used within the multi material
  24243. */
  24244. getChildren(): Nullable<Material>[];
  24245. /**
  24246. * Instantiates a new Multi Material
  24247. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24248. * separate meshes. This can be use to improve performances.
  24249. * @see http://doc.babylonjs.com/how_to/multi_materials
  24250. * @param name Define the name in the scene
  24251. * @param scene Define the scene the material belongs to
  24252. */
  24253. constructor(name: string, scene: Scene);
  24254. private _hookArray;
  24255. /**
  24256. * Get one of the submaterial by its index in the submaterials array
  24257. * @param index The index to look the sub material at
  24258. * @returns The Material if the index has been defined
  24259. */
  24260. getSubMaterial(index: number): Nullable<Material>;
  24261. /**
  24262. * Get the list of active textures for the whole sub materials list.
  24263. * @returns All the textures that will be used during the rendering
  24264. */
  24265. getActiveTextures(): BaseTexture[];
  24266. /**
  24267. * Gets the current class name of the material e.g. "MultiMaterial"
  24268. * Mainly use in serialization.
  24269. * @returns the class name
  24270. */
  24271. getClassName(): string;
  24272. /**
  24273. * Checks if the material is ready to render the requested sub mesh
  24274. * @param mesh Define the mesh the submesh belongs to
  24275. * @param subMesh Define the sub mesh to look readyness for
  24276. * @param useInstances Define whether or not the material is used with instances
  24277. * @returns true if ready, otherwise false
  24278. */
  24279. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  24280. /**
  24281. * Clones the current material and its related sub materials
  24282. * @param name Define the name of the newly cloned material
  24283. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  24284. * @returns the cloned material
  24285. */
  24286. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  24287. /**
  24288. * Serializes the materials into a JSON representation.
  24289. * @returns the JSON representation
  24290. */
  24291. serialize(): any;
  24292. /**
  24293. * Dispose the material and release its associated resources
  24294. * @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)
  24295. * @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)
  24296. * @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)
  24297. */
  24298. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  24299. /**
  24300. * Creates a MultiMaterial from parsed MultiMaterial data.
  24301. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  24302. * @param scene defines the hosting scene
  24303. * @returns a new MultiMaterial
  24304. */
  24305. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  24306. }
  24307. }
  24308. declare module BABYLON {
  24309. /**
  24310. * Base class for submeshes
  24311. */
  24312. export class BaseSubMesh {
  24313. /** @hidden */
  24314. _materialDefines: Nullable<MaterialDefines>;
  24315. /** @hidden */
  24316. _materialEffect: Nullable<Effect>;
  24317. /** @hidden */
  24318. _effectOverride: Nullable<Effect>;
  24319. /**
  24320. * Gets material defines used by the effect associated to the sub mesh
  24321. */
  24322. get materialDefines(): Nullable<MaterialDefines>;
  24323. /**
  24324. * Sets material defines used by the effect associated to the sub mesh
  24325. */
  24326. set materialDefines(defines: Nullable<MaterialDefines>);
  24327. /**
  24328. * Gets associated effect
  24329. */
  24330. get effect(): Nullable<Effect>;
  24331. /**
  24332. * Sets associated effect (effect used to render this submesh)
  24333. * @param effect defines the effect to associate with
  24334. * @param defines defines the set of defines used to compile this effect
  24335. */
  24336. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  24337. }
  24338. /**
  24339. * Defines a subdivision inside a mesh
  24340. */
  24341. export class SubMesh extends BaseSubMesh implements ICullable {
  24342. /** the material index to use */
  24343. materialIndex: number;
  24344. /** vertex index start */
  24345. verticesStart: number;
  24346. /** vertices count */
  24347. verticesCount: number;
  24348. /** index start */
  24349. indexStart: number;
  24350. /** indices count */
  24351. indexCount: number;
  24352. /** @hidden */
  24353. _linesIndexCount: number;
  24354. private _mesh;
  24355. private _renderingMesh;
  24356. private _boundingInfo;
  24357. private _linesIndexBuffer;
  24358. /** @hidden */
  24359. _lastColliderWorldVertices: Nullable<Vector3[]>;
  24360. /** @hidden */
  24361. _trianglePlanes: Plane[];
  24362. /** @hidden */
  24363. _lastColliderTransformMatrix: Nullable<Matrix>;
  24364. /** @hidden */
  24365. _renderId: number;
  24366. /** @hidden */
  24367. _alphaIndex: number;
  24368. /** @hidden */
  24369. _distanceToCamera: number;
  24370. /** @hidden */
  24371. _id: number;
  24372. private _currentMaterial;
  24373. /**
  24374. * Add a new submesh to a mesh
  24375. * @param materialIndex defines the material index to use
  24376. * @param verticesStart defines vertex index start
  24377. * @param verticesCount defines vertices count
  24378. * @param indexStart defines index start
  24379. * @param indexCount defines indices count
  24380. * @param mesh defines the parent mesh
  24381. * @param renderingMesh defines an optional rendering mesh
  24382. * @param createBoundingBox defines if bounding box should be created for this submesh
  24383. * @returns the new submesh
  24384. */
  24385. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  24386. /**
  24387. * Creates a new submesh
  24388. * @param materialIndex defines the material index to use
  24389. * @param verticesStart defines vertex index start
  24390. * @param verticesCount defines vertices count
  24391. * @param indexStart defines index start
  24392. * @param indexCount defines indices count
  24393. * @param mesh defines the parent mesh
  24394. * @param renderingMesh defines an optional rendering mesh
  24395. * @param createBoundingBox defines if bounding box should be created for this submesh
  24396. */
  24397. constructor(
  24398. /** the material index to use */
  24399. materialIndex: number,
  24400. /** vertex index start */
  24401. verticesStart: number,
  24402. /** vertices count */
  24403. verticesCount: number,
  24404. /** index start */
  24405. indexStart: number,
  24406. /** indices count */
  24407. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  24408. /**
  24409. * Returns true if this submesh covers the entire parent mesh
  24410. * @ignorenaming
  24411. */
  24412. get IsGlobal(): boolean;
  24413. /**
  24414. * Returns the submesh BoudingInfo object
  24415. * @returns current bounding info (or mesh's one if the submesh is global)
  24416. */
  24417. getBoundingInfo(): BoundingInfo;
  24418. /**
  24419. * Sets the submesh BoundingInfo
  24420. * @param boundingInfo defines the new bounding info to use
  24421. * @returns the SubMesh
  24422. */
  24423. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  24424. /**
  24425. * Returns the mesh of the current submesh
  24426. * @return the parent mesh
  24427. */
  24428. getMesh(): AbstractMesh;
  24429. /**
  24430. * Returns the rendering mesh of the submesh
  24431. * @returns the rendering mesh (could be different from parent mesh)
  24432. */
  24433. getRenderingMesh(): Mesh;
  24434. /**
  24435. * Returns the submesh material
  24436. * @returns null or the current material
  24437. */
  24438. getMaterial(): Nullable<Material>;
  24439. /**
  24440. * Sets a new updated BoundingInfo object to the submesh
  24441. * @param data defines an optional position array to use to determine the bounding info
  24442. * @returns the SubMesh
  24443. */
  24444. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  24445. /** @hidden */
  24446. _checkCollision(collider: Collider): boolean;
  24447. /**
  24448. * Updates the submesh BoundingInfo
  24449. * @param world defines the world matrix to use to update the bounding info
  24450. * @returns the submesh
  24451. */
  24452. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  24453. /**
  24454. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  24455. * @param frustumPlanes defines the frustum planes
  24456. * @returns true if the submesh is intersecting with the frustum
  24457. */
  24458. isInFrustum(frustumPlanes: Plane[]): boolean;
  24459. /**
  24460. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  24461. * @param frustumPlanes defines the frustum planes
  24462. * @returns true if the submesh is inside the frustum
  24463. */
  24464. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24465. /**
  24466. * Renders the submesh
  24467. * @param enableAlphaMode defines if alpha needs to be used
  24468. * @returns the submesh
  24469. */
  24470. render(enableAlphaMode: boolean): SubMesh;
  24471. /**
  24472. * @hidden
  24473. */
  24474. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  24475. /**
  24476. * Checks if the submesh intersects with a ray
  24477. * @param ray defines the ray to test
  24478. * @returns true is the passed ray intersects the submesh bounding box
  24479. */
  24480. canIntersects(ray: Ray): boolean;
  24481. /**
  24482. * Intersects current submesh with a ray
  24483. * @param ray defines the ray to test
  24484. * @param positions defines mesh's positions array
  24485. * @param indices defines mesh's indices array
  24486. * @param fastCheck defines if the first intersection will be used (and not the closest)
  24487. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24488. * @returns intersection info or null if no intersection
  24489. */
  24490. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  24491. /** @hidden */
  24492. private _intersectLines;
  24493. /** @hidden */
  24494. private _intersectUnIndexedLines;
  24495. /** @hidden */
  24496. private _intersectTriangles;
  24497. /** @hidden */
  24498. private _intersectUnIndexedTriangles;
  24499. /** @hidden */
  24500. _rebuild(): void;
  24501. /**
  24502. * Creates a new submesh from the passed mesh
  24503. * @param newMesh defines the new hosting mesh
  24504. * @param newRenderingMesh defines an optional rendering mesh
  24505. * @returns the new submesh
  24506. */
  24507. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  24508. /**
  24509. * Release associated resources
  24510. */
  24511. dispose(): void;
  24512. /**
  24513. * Gets the class name
  24514. * @returns the string "SubMesh".
  24515. */
  24516. getClassName(): string;
  24517. /**
  24518. * Creates a new submesh from indices data
  24519. * @param materialIndex the index of the main mesh material
  24520. * @param startIndex the index where to start the copy in the mesh indices array
  24521. * @param indexCount the number of indices to copy then from the startIndex
  24522. * @param mesh the main mesh to create the submesh from
  24523. * @param renderingMesh the optional rendering mesh
  24524. * @returns a new submesh
  24525. */
  24526. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  24527. }
  24528. }
  24529. declare module BABYLON {
  24530. /**
  24531. * Class used to represent data loading progression
  24532. */
  24533. export class SceneLoaderFlags {
  24534. private static _ForceFullSceneLoadingForIncremental;
  24535. private static _ShowLoadingScreen;
  24536. private static _CleanBoneMatrixWeights;
  24537. private static _loggingLevel;
  24538. /**
  24539. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  24540. */
  24541. static get ForceFullSceneLoadingForIncremental(): boolean;
  24542. static set ForceFullSceneLoadingForIncremental(value: boolean);
  24543. /**
  24544. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  24545. */
  24546. static get ShowLoadingScreen(): boolean;
  24547. static set ShowLoadingScreen(value: boolean);
  24548. /**
  24549. * Defines the current logging level (while loading the scene)
  24550. * @ignorenaming
  24551. */
  24552. static get loggingLevel(): number;
  24553. static set loggingLevel(value: number);
  24554. /**
  24555. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  24556. */
  24557. static get CleanBoneMatrixWeights(): boolean;
  24558. static set CleanBoneMatrixWeights(value: boolean);
  24559. }
  24560. }
  24561. declare module BABYLON {
  24562. /**
  24563. * Class used to store geometry data (vertex buffers + index buffer)
  24564. */
  24565. export class Geometry implements IGetSetVerticesData {
  24566. /**
  24567. * Gets or sets the ID of the geometry
  24568. */
  24569. id: string;
  24570. /**
  24571. * Gets or sets the unique ID of the geometry
  24572. */
  24573. uniqueId: number;
  24574. /**
  24575. * Gets the delay loading state of the geometry (none by default which means not delayed)
  24576. */
  24577. delayLoadState: number;
  24578. /**
  24579. * Gets the file containing the data to load when running in delay load state
  24580. */
  24581. delayLoadingFile: Nullable<string>;
  24582. /**
  24583. * Callback called when the geometry is updated
  24584. */
  24585. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  24586. private _scene;
  24587. private _engine;
  24588. private _meshes;
  24589. private _totalVertices;
  24590. /** @hidden */
  24591. _indices: IndicesArray;
  24592. /** @hidden */
  24593. _vertexBuffers: {
  24594. [key: string]: VertexBuffer;
  24595. };
  24596. private _isDisposed;
  24597. private _extend;
  24598. private _boundingBias;
  24599. /** @hidden */
  24600. _delayInfo: Array<string>;
  24601. private _indexBuffer;
  24602. private _indexBufferIsUpdatable;
  24603. /** @hidden */
  24604. _boundingInfo: Nullable<BoundingInfo>;
  24605. /** @hidden */
  24606. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  24607. /** @hidden */
  24608. _softwareSkinningFrameId: number;
  24609. private _vertexArrayObjects;
  24610. private _updatable;
  24611. /** @hidden */
  24612. _positions: Nullable<Vector3[]>;
  24613. /**
  24614. * 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
  24615. */
  24616. get boundingBias(): Vector2;
  24617. /**
  24618. * 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
  24619. */
  24620. set boundingBias(value: Vector2);
  24621. /**
  24622. * Static function used to attach a new empty geometry to a mesh
  24623. * @param mesh defines the mesh to attach the geometry to
  24624. * @returns the new Geometry
  24625. */
  24626. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  24627. /** Get the list of meshes using this geometry */
  24628. get meshes(): Mesh[];
  24629. /**
  24630. * Creates a new geometry
  24631. * @param id defines the unique ID
  24632. * @param scene defines the hosting scene
  24633. * @param vertexData defines the VertexData used to get geometry data
  24634. * @param updatable defines if geometry must be updatable (false by default)
  24635. * @param mesh defines the mesh that will be associated with the geometry
  24636. */
  24637. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  24638. /**
  24639. * Gets the current extend of the geometry
  24640. */
  24641. get extend(): {
  24642. minimum: Vector3;
  24643. maximum: Vector3;
  24644. };
  24645. /**
  24646. * Gets the hosting scene
  24647. * @returns the hosting Scene
  24648. */
  24649. getScene(): Scene;
  24650. /**
  24651. * Gets the hosting engine
  24652. * @returns the hosting Engine
  24653. */
  24654. getEngine(): Engine;
  24655. /**
  24656. * Defines if the geometry is ready to use
  24657. * @returns true if the geometry is ready to be used
  24658. */
  24659. isReady(): boolean;
  24660. /**
  24661. * Gets a value indicating that the geometry should not be serialized
  24662. */
  24663. get doNotSerialize(): boolean;
  24664. /** @hidden */
  24665. _rebuild(): void;
  24666. /**
  24667. * Affects all geometry data in one call
  24668. * @param vertexData defines the geometry data
  24669. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  24670. */
  24671. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  24672. /**
  24673. * Set specific vertex data
  24674. * @param kind defines the data kind (Position, normal, etc...)
  24675. * @param data defines the vertex data to use
  24676. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  24677. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  24678. */
  24679. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  24680. /**
  24681. * Removes a specific vertex data
  24682. * @param kind defines the data kind (Position, normal, etc...)
  24683. */
  24684. removeVerticesData(kind: string): void;
  24685. /**
  24686. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  24687. * @param buffer defines the vertex buffer to use
  24688. * @param totalVertices defines the total number of vertices for position kind (could be null)
  24689. */
  24690. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  24691. /**
  24692. * Update a specific vertex buffer
  24693. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  24694. * It will do nothing if the buffer is not updatable
  24695. * @param kind defines the data kind (Position, normal, etc...)
  24696. * @param data defines the data to use
  24697. * @param offset defines the offset in the target buffer where to store the data
  24698. * @param useBytes set to true if the offset is in bytes
  24699. */
  24700. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  24701. /**
  24702. * Update a specific vertex buffer
  24703. * This function will create a new buffer if the current one is not updatable
  24704. * @param kind defines the data kind (Position, normal, etc...)
  24705. * @param data defines the data to use
  24706. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  24707. */
  24708. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  24709. private _updateBoundingInfo;
  24710. /** @hidden */
  24711. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  24712. /**
  24713. * Gets total number of vertices
  24714. * @returns the total number of vertices
  24715. */
  24716. getTotalVertices(): number;
  24717. /**
  24718. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  24719. * @param kind defines the data kind (Position, normal, etc...)
  24720. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24721. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24722. * @returns a float array containing vertex data
  24723. */
  24724. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24725. /**
  24726. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  24727. * @param kind defines the data kind (Position, normal, etc...)
  24728. * @returns true if the vertex buffer with the specified kind is updatable
  24729. */
  24730. isVertexBufferUpdatable(kind: string): boolean;
  24731. /**
  24732. * Gets a specific vertex buffer
  24733. * @param kind defines the data kind (Position, normal, etc...)
  24734. * @returns a VertexBuffer
  24735. */
  24736. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24737. /**
  24738. * Returns all vertex buffers
  24739. * @return an object holding all vertex buffers indexed by kind
  24740. */
  24741. getVertexBuffers(): Nullable<{
  24742. [key: string]: VertexBuffer;
  24743. }>;
  24744. /**
  24745. * Gets a boolean indicating if specific vertex buffer is present
  24746. * @param kind defines the data kind (Position, normal, etc...)
  24747. * @returns true if data is present
  24748. */
  24749. isVerticesDataPresent(kind: string): boolean;
  24750. /**
  24751. * Gets a list of all attached data kinds (Position, normal, etc...)
  24752. * @returns a list of string containing all kinds
  24753. */
  24754. getVerticesDataKinds(): string[];
  24755. /**
  24756. * Update index buffer
  24757. * @param indices defines the indices to store in the index buffer
  24758. * @param offset defines the offset in the target buffer where to store the data
  24759. * @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)
  24760. */
  24761. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  24762. /**
  24763. * Creates a new index buffer
  24764. * @param indices defines the indices to store in the index buffer
  24765. * @param totalVertices defines the total number of vertices (could be null)
  24766. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  24767. */
  24768. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  24769. /**
  24770. * Return the total number of indices
  24771. * @returns the total number of indices
  24772. */
  24773. getTotalIndices(): number;
  24774. /**
  24775. * Gets the index buffer array
  24776. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24777. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24778. * @returns the index buffer array
  24779. */
  24780. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24781. /**
  24782. * Gets the index buffer
  24783. * @return the index buffer
  24784. */
  24785. getIndexBuffer(): Nullable<DataBuffer>;
  24786. /** @hidden */
  24787. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  24788. /**
  24789. * Release the associated resources for a specific mesh
  24790. * @param mesh defines the source mesh
  24791. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  24792. */
  24793. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  24794. /**
  24795. * Apply current geometry to a given mesh
  24796. * @param mesh defines the mesh to apply geometry to
  24797. */
  24798. applyToMesh(mesh: Mesh): void;
  24799. private _updateExtend;
  24800. private _applyToMesh;
  24801. private notifyUpdate;
  24802. /**
  24803. * Load the geometry if it was flagged as delay loaded
  24804. * @param scene defines the hosting scene
  24805. * @param onLoaded defines a callback called when the geometry is loaded
  24806. */
  24807. load(scene: Scene, onLoaded?: () => void): void;
  24808. private _queueLoad;
  24809. /**
  24810. * Invert the geometry to move from a right handed system to a left handed one.
  24811. */
  24812. toLeftHanded(): void;
  24813. /** @hidden */
  24814. _resetPointsArrayCache(): void;
  24815. /** @hidden */
  24816. _generatePointsArray(): boolean;
  24817. /**
  24818. * Gets a value indicating if the geometry is disposed
  24819. * @returns true if the geometry was disposed
  24820. */
  24821. isDisposed(): boolean;
  24822. private _disposeVertexArrayObjects;
  24823. /**
  24824. * Free all associated resources
  24825. */
  24826. dispose(): void;
  24827. /**
  24828. * Clone the current geometry into a new geometry
  24829. * @param id defines the unique ID of the new geometry
  24830. * @returns a new geometry object
  24831. */
  24832. copy(id: string): Geometry;
  24833. /**
  24834. * Serialize the current geometry info (and not the vertices data) into a JSON object
  24835. * @return a JSON representation of the current geometry data (without the vertices data)
  24836. */
  24837. serialize(): any;
  24838. private toNumberArray;
  24839. /**
  24840. * Serialize all vertices data into a JSON oject
  24841. * @returns a JSON representation of the current geometry data
  24842. */
  24843. serializeVerticeData(): any;
  24844. /**
  24845. * Extracts a clone of a mesh geometry
  24846. * @param mesh defines the source mesh
  24847. * @param id defines the unique ID of the new geometry object
  24848. * @returns the new geometry object
  24849. */
  24850. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  24851. /**
  24852. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  24853. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24854. * Be aware Math.random() could cause collisions, but:
  24855. * "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"
  24856. * @returns a string containing a new GUID
  24857. */
  24858. static RandomId(): string;
  24859. /** @hidden */
  24860. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  24861. private static _CleanMatricesWeights;
  24862. /**
  24863. * Create a new geometry from persisted data (Using .babylon file format)
  24864. * @param parsedVertexData defines the persisted data
  24865. * @param scene defines the hosting scene
  24866. * @param rootUrl defines the root url to use to load assets (like delayed data)
  24867. * @returns the new geometry object
  24868. */
  24869. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  24870. }
  24871. }
  24872. declare module BABYLON {
  24873. /**
  24874. * Define an interface for all classes that will get and set the data on vertices
  24875. */
  24876. export interface IGetSetVerticesData {
  24877. /**
  24878. * Gets a boolean indicating if specific vertex data is present
  24879. * @param kind defines the vertex data kind to use
  24880. * @returns true is data kind is present
  24881. */
  24882. isVerticesDataPresent(kind: string): boolean;
  24883. /**
  24884. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  24885. * @param kind defines the data kind (Position, normal, etc...)
  24886. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24887. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24888. * @returns a float array containing vertex data
  24889. */
  24890. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24891. /**
  24892. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24893. * @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.
  24894. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24895. * @returns the indices array or an empty array if the mesh has no geometry
  24896. */
  24897. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24898. /**
  24899. * Set specific vertex data
  24900. * @param kind defines the data kind (Position, normal, etc...)
  24901. * @param data defines the vertex data to use
  24902. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  24903. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  24904. */
  24905. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  24906. /**
  24907. * Update a specific associated vertex buffer
  24908. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24909. * - VertexBuffer.PositionKind
  24910. * - VertexBuffer.UVKind
  24911. * - VertexBuffer.UV2Kind
  24912. * - VertexBuffer.UV3Kind
  24913. * - VertexBuffer.UV4Kind
  24914. * - VertexBuffer.UV5Kind
  24915. * - VertexBuffer.UV6Kind
  24916. * - VertexBuffer.ColorKind
  24917. * - VertexBuffer.MatricesIndicesKind
  24918. * - VertexBuffer.MatricesIndicesExtraKind
  24919. * - VertexBuffer.MatricesWeightsKind
  24920. * - VertexBuffer.MatricesWeightsExtraKind
  24921. * @param data defines the data source
  24922. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24923. * @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)
  24924. */
  24925. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  24926. /**
  24927. * Creates a new index buffer
  24928. * @param indices defines the indices to store in the index buffer
  24929. * @param totalVertices defines the total number of vertices (could be null)
  24930. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  24931. */
  24932. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  24933. }
  24934. /**
  24935. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  24936. */
  24937. export class VertexData {
  24938. /**
  24939. * Mesh side orientation : usually the external or front surface
  24940. */
  24941. static readonly FRONTSIDE: number;
  24942. /**
  24943. * Mesh side orientation : usually the internal or back surface
  24944. */
  24945. static readonly BACKSIDE: number;
  24946. /**
  24947. * Mesh side orientation : both internal and external or front and back surfaces
  24948. */
  24949. static readonly DOUBLESIDE: number;
  24950. /**
  24951. * Mesh side orientation : by default, `FRONTSIDE`
  24952. */
  24953. static readonly DEFAULTSIDE: number;
  24954. /**
  24955. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  24956. */
  24957. positions: Nullable<FloatArray>;
  24958. /**
  24959. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  24960. */
  24961. normals: Nullable<FloatArray>;
  24962. /**
  24963. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  24964. */
  24965. tangents: Nullable<FloatArray>;
  24966. /**
  24967. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  24968. */
  24969. uvs: Nullable<FloatArray>;
  24970. /**
  24971. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  24972. */
  24973. uvs2: Nullable<FloatArray>;
  24974. /**
  24975. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  24976. */
  24977. uvs3: Nullable<FloatArray>;
  24978. /**
  24979. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  24980. */
  24981. uvs4: Nullable<FloatArray>;
  24982. /**
  24983. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  24984. */
  24985. uvs5: Nullable<FloatArray>;
  24986. /**
  24987. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  24988. */
  24989. uvs6: Nullable<FloatArray>;
  24990. /**
  24991. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  24992. */
  24993. colors: Nullable<FloatArray>;
  24994. /**
  24995. * 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).
  24996. */
  24997. matricesIndices: Nullable<FloatArray>;
  24998. /**
  24999. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25000. */
  25001. matricesWeights: Nullable<FloatArray>;
  25002. /**
  25003. * An array extending the number of possible indices
  25004. */
  25005. matricesIndicesExtra: Nullable<FloatArray>;
  25006. /**
  25007. * An array extending the number of possible weights when the number of indices is extended
  25008. */
  25009. matricesWeightsExtra: Nullable<FloatArray>;
  25010. /**
  25011. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25012. */
  25013. indices: Nullable<IndicesArray>;
  25014. /**
  25015. * Uses the passed data array to set the set the values for the specified kind of data
  25016. * @param data a linear array of floating numbers
  25017. * @param kind the type of data that is being set, eg positions, colors etc
  25018. */
  25019. set(data: FloatArray, kind: string): void;
  25020. /**
  25021. * Associates the vertexData to the passed Mesh.
  25022. * Sets it as updatable or not (default `false`)
  25023. * @param mesh the mesh the vertexData is applied to
  25024. * @param updatable when used and having the value true allows new data to update the vertexData
  25025. * @returns the VertexData
  25026. */
  25027. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  25028. /**
  25029. * Associates the vertexData to the passed Geometry.
  25030. * Sets it as updatable or not (default `false`)
  25031. * @param geometry the geometry the vertexData is applied to
  25032. * @param updatable when used and having the value true allows new data to update the vertexData
  25033. * @returns VertexData
  25034. */
  25035. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  25036. /**
  25037. * Updates the associated mesh
  25038. * @param mesh the mesh to be updated
  25039. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25040. * @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
  25041. * @returns VertexData
  25042. */
  25043. updateMesh(mesh: Mesh): VertexData;
  25044. /**
  25045. * Updates the associated geometry
  25046. * @param geometry the geometry to be updated
  25047. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25048. * @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
  25049. * @returns VertexData.
  25050. */
  25051. updateGeometry(geometry: Geometry): VertexData;
  25052. private _applyTo;
  25053. private _update;
  25054. /**
  25055. * Transforms each position and each normal of the vertexData according to the passed Matrix
  25056. * @param matrix the transforming matrix
  25057. * @returns the VertexData
  25058. */
  25059. transform(matrix: Matrix): VertexData;
  25060. /**
  25061. * Merges the passed VertexData into the current one
  25062. * @param other the VertexData to be merged into the current one
  25063. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  25064. * @returns the modified VertexData
  25065. */
  25066. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  25067. private _mergeElement;
  25068. private _validate;
  25069. /**
  25070. * Serializes the VertexData
  25071. * @returns a serialized object
  25072. */
  25073. serialize(): any;
  25074. /**
  25075. * Extracts the vertexData from a mesh
  25076. * @param mesh the mesh from which to extract the VertexData
  25077. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  25078. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25079. * @returns the object VertexData associated to the passed mesh
  25080. */
  25081. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25082. /**
  25083. * Extracts the vertexData from the geometry
  25084. * @param geometry the geometry from which to extract the VertexData
  25085. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  25086. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25087. * @returns the object VertexData associated to the passed mesh
  25088. */
  25089. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25090. private static _ExtractFrom;
  25091. /**
  25092. * Creates the VertexData for a Ribbon
  25093. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  25094. * * pathArray array of paths, each of which an array of successive Vector3
  25095. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  25096. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  25097. * * 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
  25098. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25099. * * 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)
  25100. * * 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)
  25101. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  25102. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  25103. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  25104. * @returns the VertexData of the ribbon
  25105. */
  25106. static CreateRibbon(options: {
  25107. pathArray: Vector3[][];
  25108. closeArray?: boolean;
  25109. closePath?: boolean;
  25110. offset?: number;
  25111. sideOrientation?: number;
  25112. frontUVs?: Vector4;
  25113. backUVs?: Vector4;
  25114. invertUV?: boolean;
  25115. uvs?: Vector2[];
  25116. colors?: Color4[];
  25117. }): VertexData;
  25118. /**
  25119. * Creates the VertexData for a box
  25120. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25121. * * size sets the width, height and depth of the box to the value of size, optional default 1
  25122. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  25123. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  25124. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  25125. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25126. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25127. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25128. * * 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)
  25129. * * 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)
  25130. * @returns the VertexData of the box
  25131. */
  25132. static CreateBox(options: {
  25133. size?: number;
  25134. width?: number;
  25135. height?: number;
  25136. depth?: number;
  25137. faceUV?: Vector4[];
  25138. faceColors?: Color4[];
  25139. sideOrientation?: number;
  25140. frontUVs?: Vector4;
  25141. backUVs?: Vector4;
  25142. }): VertexData;
  25143. /**
  25144. * Creates the VertexData for a tiled box
  25145. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25146. * * faceTiles sets the pattern, tile size and number of tiles for a face
  25147. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25148. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25149. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25150. * @returns the VertexData of the box
  25151. */
  25152. static CreateTiledBox(options: {
  25153. pattern?: number;
  25154. width?: number;
  25155. height?: number;
  25156. depth?: number;
  25157. tileSize?: number;
  25158. tileWidth?: number;
  25159. tileHeight?: number;
  25160. alignHorizontal?: number;
  25161. alignVertical?: number;
  25162. faceUV?: Vector4[];
  25163. faceColors?: Color4[];
  25164. sideOrientation?: number;
  25165. }): VertexData;
  25166. /**
  25167. * Creates the VertexData for a tiled plane
  25168. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25169. * * pattern a limited pattern arrangement depending on the number
  25170. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  25171. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  25172. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  25173. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25174. * * 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)
  25175. * * 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)
  25176. * @returns the VertexData of the tiled plane
  25177. */
  25178. static CreateTiledPlane(options: {
  25179. pattern?: number;
  25180. tileSize?: number;
  25181. tileWidth?: number;
  25182. tileHeight?: number;
  25183. size?: number;
  25184. width?: number;
  25185. height?: number;
  25186. alignHorizontal?: number;
  25187. alignVertical?: number;
  25188. sideOrientation?: number;
  25189. frontUVs?: Vector4;
  25190. backUVs?: Vector4;
  25191. }): VertexData;
  25192. /**
  25193. * Creates the VertexData for an ellipsoid, defaults to a sphere
  25194. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25195. * * segments sets the number of horizontal strips optional, default 32
  25196. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  25197. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  25198. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  25199. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  25200. * * 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
  25201. * * 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
  25202. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25203. * * 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)
  25204. * * 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)
  25205. * @returns the VertexData of the ellipsoid
  25206. */
  25207. static CreateSphere(options: {
  25208. segments?: number;
  25209. diameter?: number;
  25210. diameterX?: number;
  25211. diameterY?: number;
  25212. diameterZ?: number;
  25213. arc?: number;
  25214. slice?: number;
  25215. sideOrientation?: number;
  25216. frontUVs?: Vector4;
  25217. backUVs?: Vector4;
  25218. }): VertexData;
  25219. /**
  25220. * Creates the VertexData for a cylinder, cone or prism
  25221. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25222. * * height sets the height (y direction) of the cylinder, optional, default 2
  25223. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  25224. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  25225. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  25226. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25227. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  25228. * * 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
  25229. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25230. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25231. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  25232. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  25233. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25234. * * 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)
  25235. * * 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)
  25236. * @returns the VertexData of the cylinder, cone or prism
  25237. */
  25238. static CreateCylinder(options: {
  25239. height?: number;
  25240. diameterTop?: number;
  25241. diameterBottom?: number;
  25242. diameter?: number;
  25243. tessellation?: number;
  25244. subdivisions?: number;
  25245. arc?: number;
  25246. faceColors?: Color4[];
  25247. faceUV?: Vector4[];
  25248. hasRings?: boolean;
  25249. enclose?: boolean;
  25250. sideOrientation?: number;
  25251. frontUVs?: Vector4;
  25252. backUVs?: Vector4;
  25253. }): VertexData;
  25254. /**
  25255. * Creates the VertexData for a torus
  25256. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25257. * * diameter the diameter of the torus, optional default 1
  25258. * * thickness the diameter of the tube forming the torus, optional default 0.5
  25259. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25260. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25261. * * 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)
  25262. * * 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)
  25263. * @returns the VertexData of the torus
  25264. */
  25265. static CreateTorus(options: {
  25266. diameter?: number;
  25267. thickness?: number;
  25268. tessellation?: number;
  25269. sideOrientation?: number;
  25270. frontUVs?: Vector4;
  25271. backUVs?: Vector4;
  25272. }): VertexData;
  25273. /**
  25274. * Creates the VertexData of the LineSystem
  25275. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  25276. * - lines an array of lines, each line being an array of successive Vector3
  25277. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  25278. * @returns the VertexData of the LineSystem
  25279. */
  25280. static CreateLineSystem(options: {
  25281. lines: Vector3[][];
  25282. colors?: Nullable<Color4[][]>;
  25283. }): VertexData;
  25284. /**
  25285. * Create the VertexData for a DashedLines
  25286. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  25287. * - points an array successive Vector3
  25288. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  25289. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  25290. * - dashNb the intended total number of dashes, optional, default 200
  25291. * @returns the VertexData for the DashedLines
  25292. */
  25293. static CreateDashedLines(options: {
  25294. points: Vector3[];
  25295. dashSize?: number;
  25296. gapSize?: number;
  25297. dashNb?: number;
  25298. }): VertexData;
  25299. /**
  25300. * Creates the VertexData for a Ground
  25301. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25302. * - width the width (x direction) of the ground, optional, default 1
  25303. * - height the height (z direction) of the ground, optional, default 1
  25304. * - subdivisions the number of subdivisions per side, optional, default 1
  25305. * @returns the VertexData of the Ground
  25306. */
  25307. static CreateGround(options: {
  25308. width?: number;
  25309. height?: number;
  25310. subdivisions?: number;
  25311. subdivisionsX?: number;
  25312. subdivisionsY?: number;
  25313. }): VertexData;
  25314. /**
  25315. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  25316. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25317. * * xmin the ground minimum X coordinate, optional, default -1
  25318. * * zmin the ground minimum Z coordinate, optional, default -1
  25319. * * xmax the ground maximum X coordinate, optional, default 1
  25320. * * zmax the ground maximum Z coordinate, optional, default 1
  25321. * * 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}
  25322. * * 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}
  25323. * @returns the VertexData of the TiledGround
  25324. */
  25325. static CreateTiledGround(options: {
  25326. xmin: number;
  25327. zmin: number;
  25328. xmax: number;
  25329. zmax: number;
  25330. subdivisions?: {
  25331. w: number;
  25332. h: number;
  25333. };
  25334. precision?: {
  25335. w: number;
  25336. h: number;
  25337. };
  25338. }): VertexData;
  25339. /**
  25340. * Creates the VertexData of the Ground designed from a heightmap
  25341. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  25342. * * width the width (x direction) of the ground
  25343. * * height the height (z direction) of the ground
  25344. * * subdivisions the number of subdivisions per side
  25345. * * minHeight the minimum altitude on the ground, optional, default 0
  25346. * * maxHeight the maximum altitude on the ground, optional default 1
  25347. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  25348. * * buffer the array holding the image color data
  25349. * * bufferWidth the width of image
  25350. * * bufferHeight the height of image
  25351. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  25352. * @returns the VertexData of the Ground designed from a heightmap
  25353. */
  25354. static CreateGroundFromHeightMap(options: {
  25355. width: number;
  25356. height: number;
  25357. subdivisions: number;
  25358. minHeight: number;
  25359. maxHeight: number;
  25360. colorFilter: Color3;
  25361. buffer: Uint8Array;
  25362. bufferWidth: number;
  25363. bufferHeight: number;
  25364. alphaFilter: number;
  25365. }): VertexData;
  25366. /**
  25367. * Creates the VertexData for a Plane
  25368. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  25369. * * size sets the width and height of the plane to the value of size, optional default 1
  25370. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  25371. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  25372. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25373. * * 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)
  25374. * * 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)
  25375. * @returns the VertexData of the box
  25376. */
  25377. static CreatePlane(options: {
  25378. size?: number;
  25379. width?: number;
  25380. height?: number;
  25381. sideOrientation?: number;
  25382. frontUVs?: Vector4;
  25383. backUVs?: Vector4;
  25384. }): VertexData;
  25385. /**
  25386. * Creates the VertexData of the Disc or regular Polygon
  25387. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  25388. * * radius the radius of the disc, optional default 0.5
  25389. * * tessellation the number of polygon sides, optional, default 64
  25390. * * 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
  25391. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25392. * * 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)
  25393. * * 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)
  25394. * @returns the VertexData of the box
  25395. */
  25396. static CreateDisc(options: {
  25397. radius?: number;
  25398. tessellation?: number;
  25399. arc?: number;
  25400. sideOrientation?: number;
  25401. frontUVs?: Vector4;
  25402. backUVs?: Vector4;
  25403. }): VertexData;
  25404. /**
  25405. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  25406. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  25407. * @param polygon a mesh built from polygonTriangulation.build()
  25408. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25409. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25410. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25411. * @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)
  25412. * @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)
  25413. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  25414. * @returns the VertexData of the Polygon
  25415. */
  25416. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  25417. /**
  25418. * Creates the VertexData of the IcoSphere
  25419. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  25420. * * radius the radius of the IcoSphere, optional default 1
  25421. * * radiusX allows stretching in the x direction, optional, default radius
  25422. * * radiusY allows stretching in the y direction, optional, default radius
  25423. * * radiusZ allows stretching in the z direction, optional, default radius
  25424. * * flat when true creates a flat shaded mesh, optional, default true
  25425. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25426. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25427. * * 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)
  25428. * * 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)
  25429. * @returns the VertexData of the IcoSphere
  25430. */
  25431. static CreateIcoSphere(options: {
  25432. radius?: number;
  25433. radiusX?: number;
  25434. radiusY?: number;
  25435. radiusZ?: number;
  25436. flat?: boolean;
  25437. subdivisions?: number;
  25438. sideOrientation?: number;
  25439. frontUVs?: Vector4;
  25440. backUVs?: Vector4;
  25441. }): VertexData;
  25442. /**
  25443. * Creates the VertexData for a Polyhedron
  25444. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  25445. * * type provided types are:
  25446. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  25447. * * 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)
  25448. * * size the size of the IcoSphere, optional default 1
  25449. * * sizeX allows stretching in the x direction, optional, default size
  25450. * * sizeY allows stretching in the y direction, optional, default size
  25451. * * sizeZ allows stretching in the z direction, optional, default size
  25452. * * 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
  25453. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25454. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25455. * * flat when true creates a flat shaded mesh, optional, default true
  25456. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25457. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25458. * * 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)
  25459. * * 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)
  25460. * @returns the VertexData of the Polyhedron
  25461. */
  25462. static CreatePolyhedron(options: {
  25463. type?: number;
  25464. size?: number;
  25465. sizeX?: number;
  25466. sizeY?: number;
  25467. sizeZ?: number;
  25468. custom?: any;
  25469. faceUV?: Vector4[];
  25470. faceColors?: Color4[];
  25471. flat?: boolean;
  25472. sideOrientation?: number;
  25473. frontUVs?: Vector4;
  25474. backUVs?: Vector4;
  25475. }): VertexData;
  25476. /**
  25477. * Creates the VertexData for a TorusKnot
  25478. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  25479. * * radius the radius of the torus knot, optional, default 2
  25480. * * tube the thickness of the tube, optional, default 0.5
  25481. * * radialSegments the number of sides on each tube segments, optional, default 32
  25482. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  25483. * * p the number of windings around the z axis, optional, default 2
  25484. * * q the number of windings around the x axis, optional, default 3
  25485. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25486. * * 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)
  25487. * * 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)
  25488. * @returns the VertexData of the Torus Knot
  25489. */
  25490. static CreateTorusKnot(options: {
  25491. radius?: number;
  25492. tube?: number;
  25493. radialSegments?: number;
  25494. tubularSegments?: number;
  25495. p?: number;
  25496. q?: number;
  25497. sideOrientation?: number;
  25498. frontUVs?: Vector4;
  25499. backUVs?: Vector4;
  25500. }): VertexData;
  25501. /**
  25502. * Compute normals for given positions and indices
  25503. * @param positions an array of vertex positions, [...., x, y, z, ......]
  25504. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  25505. * @param normals an array of vertex normals, [...., x, y, z, ......]
  25506. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  25507. * * facetNormals : optional array of facet normals (vector3)
  25508. * * facetPositions : optional array of facet positions (vector3)
  25509. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  25510. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  25511. * * bInfo : optional bounding info, required for facetPartitioning computation
  25512. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  25513. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  25514. * * useRightHandedSystem: optional boolean to for right handed system computation
  25515. * * depthSort : optional boolean to enable the facet depth sort computation
  25516. * * distanceTo : optional Vector3 to compute the facet depth from this location
  25517. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  25518. */
  25519. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  25520. facetNormals?: any;
  25521. facetPositions?: any;
  25522. facetPartitioning?: any;
  25523. ratio?: number;
  25524. bInfo?: any;
  25525. bbSize?: Vector3;
  25526. subDiv?: any;
  25527. useRightHandedSystem?: boolean;
  25528. depthSort?: boolean;
  25529. distanceTo?: Vector3;
  25530. depthSortedFacets?: any;
  25531. }): void;
  25532. /** @hidden */
  25533. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  25534. /**
  25535. * Applies VertexData created from the imported parameters to the geometry
  25536. * @param parsedVertexData the parsed data from an imported file
  25537. * @param geometry the geometry to apply the VertexData to
  25538. */
  25539. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  25540. }
  25541. }
  25542. declare module BABYLON {
  25543. /**
  25544. * Defines a target to use with MorphTargetManager
  25545. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25546. */
  25547. export class MorphTarget implements IAnimatable {
  25548. /** defines the name of the target */
  25549. name: string;
  25550. /**
  25551. * Gets or sets the list of animations
  25552. */
  25553. animations: Animation[];
  25554. private _scene;
  25555. private _positions;
  25556. private _normals;
  25557. private _tangents;
  25558. private _uvs;
  25559. private _influence;
  25560. private _uniqueId;
  25561. /**
  25562. * Observable raised when the influence changes
  25563. */
  25564. onInfluenceChanged: Observable<boolean>;
  25565. /** @hidden */
  25566. _onDataLayoutChanged: Observable<void>;
  25567. /**
  25568. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  25569. */
  25570. get influence(): number;
  25571. set influence(influence: number);
  25572. /**
  25573. * Gets or sets the id of the morph Target
  25574. */
  25575. id: string;
  25576. private _animationPropertiesOverride;
  25577. /**
  25578. * Gets or sets the animation properties override
  25579. */
  25580. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25581. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  25582. /**
  25583. * Creates a new MorphTarget
  25584. * @param name defines the name of the target
  25585. * @param influence defines the influence to use
  25586. * @param scene defines the scene the morphtarget belongs to
  25587. */
  25588. constructor(
  25589. /** defines the name of the target */
  25590. name: string, influence?: number, scene?: Nullable<Scene>);
  25591. /**
  25592. * Gets the unique ID of this manager
  25593. */
  25594. get uniqueId(): number;
  25595. /**
  25596. * Gets a boolean defining if the target contains position data
  25597. */
  25598. get hasPositions(): boolean;
  25599. /**
  25600. * Gets a boolean defining if the target contains normal data
  25601. */
  25602. get hasNormals(): boolean;
  25603. /**
  25604. * Gets a boolean defining if the target contains tangent data
  25605. */
  25606. get hasTangents(): boolean;
  25607. /**
  25608. * Gets a boolean defining if the target contains texture coordinates data
  25609. */
  25610. get hasUVs(): boolean;
  25611. /**
  25612. * Affects position data to this target
  25613. * @param data defines the position data to use
  25614. */
  25615. setPositions(data: Nullable<FloatArray>): void;
  25616. /**
  25617. * Gets the position data stored in this target
  25618. * @returns a FloatArray containing the position data (or null if not present)
  25619. */
  25620. getPositions(): Nullable<FloatArray>;
  25621. /**
  25622. * Affects normal data to this target
  25623. * @param data defines the normal data to use
  25624. */
  25625. setNormals(data: Nullable<FloatArray>): void;
  25626. /**
  25627. * Gets the normal data stored in this target
  25628. * @returns a FloatArray containing the normal data (or null if not present)
  25629. */
  25630. getNormals(): Nullable<FloatArray>;
  25631. /**
  25632. * Affects tangent data to this target
  25633. * @param data defines the tangent data to use
  25634. */
  25635. setTangents(data: Nullable<FloatArray>): void;
  25636. /**
  25637. * Gets the tangent data stored in this target
  25638. * @returns a FloatArray containing the tangent data (or null if not present)
  25639. */
  25640. getTangents(): Nullable<FloatArray>;
  25641. /**
  25642. * Affects texture coordinates data to this target
  25643. * @param data defines the texture coordinates data to use
  25644. */
  25645. setUVs(data: Nullable<FloatArray>): void;
  25646. /**
  25647. * Gets the texture coordinates data stored in this target
  25648. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  25649. */
  25650. getUVs(): Nullable<FloatArray>;
  25651. /**
  25652. * Clone the current target
  25653. * @returns a new MorphTarget
  25654. */
  25655. clone(): MorphTarget;
  25656. /**
  25657. * Serializes the current target into a Serialization object
  25658. * @returns the serialized object
  25659. */
  25660. serialize(): any;
  25661. /**
  25662. * Returns the string "MorphTarget"
  25663. * @returns "MorphTarget"
  25664. */
  25665. getClassName(): string;
  25666. /**
  25667. * Creates a new target from serialized data
  25668. * @param serializationObject defines the serialized data to use
  25669. * @returns a new MorphTarget
  25670. */
  25671. static Parse(serializationObject: any): MorphTarget;
  25672. /**
  25673. * Creates a MorphTarget from mesh data
  25674. * @param mesh defines the source mesh
  25675. * @param name defines the name to use for the new target
  25676. * @param influence defines the influence to attach to the target
  25677. * @returns a new MorphTarget
  25678. */
  25679. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  25680. }
  25681. }
  25682. declare module BABYLON {
  25683. /**
  25684. * This class is used to deform meshes using morphing between different targets
  25685. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25686. */
  25687. export class MorphTargetManager {
  25688. private _targets;
  25689. private _targetInfluenceChangedObservers;
  25690. private _targetDataLayoutChangedObservers;
  25691. private _activeTargets;
  25692. private _scene;
  25693. private _influences;
  25694. private _supportsNormals;
  25695. private _supportsTangents;
  25696. private _supportsUVs;
  25697. private _vertexCount;
  25698. private _uniqueId;
  25699. private _tempInfluences;
  25700. /**
  25701. * Gets or sets a boolean indicating if normals must be morphed
  25702. */
  25703. enableNormalMorphing: boolean;
  25704. /**
  25705. * Gets or sets a boolean indicating if tangents must be morphed
  25706. */
  25707. enableTangentMorphing: boolean;
  25708. /**
  25709. * Gets or sets a boolean indicating if UV must be morphed
  25710. */
  25711. enableUVMorphing: boolean;
  25712. /**
  25713. * Creates a new MorphTargetManager
  25714. * @param scene defines the current scene
  25715. */
  25716. constructor(scene?: Nullable<Scene>);
  25717. /**
  25718. * Gets the unique ID of this manager
  25719. */
  25720. get uniqueId(): number;
  25721. /**
  25722. * Gets the number of vertices handled by this manager
  25723. */
  25724. get vertexCount(): number;
  25725. /**
  25726. * Gets a boolean indicating if this manager supports morphing of normals
  25727. */
  25728. get supportsNormals(): boolean;
  25729. /**
  25730. * Gets a boolean indicating if this manager supports morphing of tangents
  25731. */
  25732. get supportsTangents(): boolean;
  25733. /**
  25734. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  25735. */
  25736. get supportsUVs(): boolean;
  25737. /**
  25738. * Gets the number of targets stored in this manager
  25739. */
  25740. get numTargets(): number;
  25741. /**
  25742. * Gets the number of influencers (ie. the number of targets with influences > 0)
  25743. */
  25744. get numInfluencers(): number;
  25745. /**
  25746. * Gets the list of influences (one per target)
  25747. */
  25748. get influences(): Float32Array;
  25749. /**
  25750. * Gets the active target at specified index. An active target is a target with an influence > 0
  25751. * @param index defines the index to check
  25752. * @returns the requested target
  25753. */
  25754. getActiveTarget(index: number): MorphTarget;
  25755. /**
  25756. * Gets the target at specified index
  25757. * @param index defines the index to check
  25758. * @returns the requested target
  25759. */
  25760. getTarget(index: number): MorphTarget;
  25761. /**
  25762. * Add a new target to this manager
  25763. * @param target defines the target to add
  25764. */
  25765. addTarget(target: MorphTarget): void;
  25766. /**
  25767. * Removes a target from the manager
  25768. * @param target defines the target to remove
  25769. */
  25770. removeTarget(target: MorphTarget): void;
  25771. /**
  25772. * Clone the current manager
  25773. * @returns a new MorphTargetManager
  25774. */
  25775. clone(): MorphTargetManager;
  25776. /**
  25777. * Serializes the current manager into a Serialization object
  25778. * @returns the serialized object
  25779. */
  25780. serialize(): any;
  25781. private _syncActiveTargets;
  25782. /**
  25783. * Syncrhonize the targets with all the meshes using this morph target manager
  25784. */
  25785. synchronize(): void;
  25786. /**
  25787. * Creates a new MorphTargetManager from serialized data
  25788. * @param serializationObject defines the serialized data
  25789. * @param scene defines the hosting scene
  25790. * @returns the new MorphTargetManager
  25791. */
  25792. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  25793. }
  25794. }
  25795. declare module BABYLON {
  25796. /**
  25797. * Class used to represent a specific level of detail of a mesh
  25798. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25799. */
  25800. export class MeshLODLevel {
  25801. /** Defines the distance where this level should start being displayed */
  25802. distance: number;
  25803. /** Defines the mesh to use to render this level */
  25804. mesh: Nullable<Mesh>;
  25805. /**
  25806. * Creates a new LOD level
  25807. * @param distance defines the distance where this level should star being displayed
  25808. * @param mesh defines the mesh to use to render this level
  25809. */
  25810. constructor(
  25811. /** Defines the distance where this level should start being displayed */
  25812. distance: number,
  25813. /** Defines the mesh to use to render this level */
  25814. mesh: Nullable<Mesh>);
  25815. }
  25816. }
  25817. declare module BABYLON {
  25818. /**
  25819. * Mesh representing the gorund
  25820. */
  25821. export class GroundMesh extends Mesh {
  25822. /** If octree should be generated */
  25823. generateOctree: boolean;
  25824. private _heightQuads;
  25825. /** @hidden */
  25826. _subdivisionsX: number;
  25827. /** @hidden */
  25828. _subdivisionsY: number;
  25829. /** @hidden */
  25830. _width: number;
  25831. /** @hidden */
  25832. _height: number;
  25833. /** @hidden */
  25834. _minX: number;
  25835. /** @hidden */
  25836. _maxX: number;
  25837. /** @hidden */
  25838. _minZ: number;
  25839. /** @hidden */
  25840. _maxZ: number;
  25841. constructor(name: string, scene: Scene);
  25842. /**
  25843. * "GroundMesh"
  25844. * @returns "GroundMesh"
  25845. */
  25846. getClassName(): string;
  25847. /**
  25848. * The minimum of x and y subdivisions
  25849. */
  25850. get subdivisions(): number;
  25851. /**
  25852. * X subdivisions
  25853. */
  25854. get subdivisionsX(): number;
  25855. /**
  25856. * Y subdivisions
  25857. */
  25858. get subdivisionsY(): number;
  25859. /**
  25860. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  25861. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  25862. * @param chunksCount the number of subdivisions for x and y
  25863. * @param octreeBlocksSize (Default: 32)
  25864. */
  25865. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  25866. /**
  25867. * Returns a height (y) value in the Worl system :
  25868. * the ground altitude at the coordinates (x, z) expressed in the World system.
  25869. * @param x x coordinate
  25870. * @param z z coordinate
  25871. * @returns the ground y position if (x, z) are outside the ground surface.
  25872. */
  25873. getHeightAtCoordinates(x: number, z: number): number;
  25874. /**
  25875. * Returns a normalized vector (Vector3) orthogonal to the ground
  25876. * at the ground coordinates (x, z) expressed in the World system.
  25877. * @param x x coordinate
  25878. * @param z z coordinate
  25879. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  25880. */
  25881. getNormalAtCoordinates(x: number, z: number): Vector3;
  25882. /**
  25883. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  25884. * at the ground coordinates (x, z) expressed in the World system.
  25885. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  25886. * @param x x coordinate
  25887. * @param z z coordinate
  25888. * @param ref vector to store the result
  25889. * @returns the GroundMesh.
  25890. */
  25891. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  25892. /**
  25893. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  25894. * if the ground has been updated.
  25895. * This can be used in the render loop.
  25896. * @returns the GroundMesh.
  25897. */
  25898. updateCoordinateHeights(): GroundMesh;
  25899. private _getFacetAt;
  25900. private _initHeightQuads;
  25901. private _computeHeightQuads;
  25902. /**
  25903. * Serializes this ground mesh
  25904. * @param serializationObject object to write serialization to
  25905. */
  25906. serialize(serializationObject: any): void;
  25907. /**
  25908. * Parses a serialized ground mesh
  25909. * @param parsedMesh the serialized mesh
  25910. * @param scene the scene to create the ground mesh in
  25911. * @returns the created ground mesh
  25912. */
  25913. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  25914. }
  25915. }
  25916. declare module BABYLON {
  25917. /**
  25918. * Interface for Physics-Joint data
  25919. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  25920. */
  25921. export interface PhysicsJointData {
  25922. /**
  25923. * The main pivot of the joint
  25924. */
  25925. mainPivot?: Vector3;
  25926. /**
  25927. * The connected pivot of the joint
  25928. */
  25929. connectedPivot?: Vector3;
  25930. /**
  25931. * The main axis of the joint
  25932. */
  25933. mainAxis?: Vector3;
  25934. /**
  25935. * The connected axis of the joint
  25936. */
  25937. connectedAxis?: Vector3;
  25938. /**
  25939. * The collision of the joint
  25940. */
  25941. collision?: boolean;
  25942. /**
  25943. * Native Oimo/Cannon/Energy data
  25944. */
  25945. nativeParams?: any;
  25946. }
  25947. /**
  25948. * This is a holder class for the physics joint created by the physics plugin
  25949. * It holds a set of functions to control the underlying joint
  25950. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  25951. */
  25952. export class PhysicsJoint {
  25953. /**
  25954. * The type of the physics joint
  25955. */
  25956. type: number;
  25957. /**
  25958. * The data for the physics joint
  25959. */
  25960. jointData: PhysicsJointData;
  25961. private _physicsJoint;
  25962. protected _physicsPlugin: IPhysicsEnginePlugin;
  25963. /**
  25964. * Initializes the physics joint
  25965. * @param type The type of the physics joint
  25966. * @param jointData The data for the physics joint
  25967. */
  25968. constructor(
  25969. /**
  25970. * The type of the physics joint
  25971. */
  25972. type: number,
  25973. /**
  25974. * The data for the physics joint
  25975. */
  25976. jointData: PhysicsJointData);
  25977. /**
  25978. * Gets the physics joint
  25979. */
  25980. get physicsJoint(): any;
  25981. /**
  25982. * Sets the physics joint
  25983. */
  25984. set physicsJoint(newJoint: any);
  25985. /**
  25986. * Sets the physics plugin
  25987. */
  25988. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  25989. /**
  25990. * Execute a function that is physics-plugin specific.
  25991. * @param {Function} func the function that will be executed.
  25992. * It accepts two parameters: the physics world and the physics joint
  25993. */
  25994. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  25995. /**
  25996. * Distance-Joint type
  25997. */
  25998. static DistanceJoint: number;
  25999. /**
  26000. * Hinge-Joint type
  26001. */
  26002. static HingeJoint: number;
  26003. /**
  26004. * Ball-and-Socket joint type
  26005. */
  26006. static BallAndSocketJoint: number;
  26007. /**
  26008. * Wheel-Joint type
  26009. */
  26010. static WheelJoint: number;
  26011. /**
  26012. * Slider-Joint type
  26013. */
  26014. static SliderJoint: number;
  26015. /**
  26016. * Prismatic-Joint type
  26017. */
  26018. static PrismaticJoint: number;
  26019. /**
  26020. * Universal-Joint type
  26021. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  26022. */
  26023. static UniversalJoint: number;
  26024. /**
  26025. * Hinge-Joint 2 type
  26026. */
  26027. static Hinge2Joint: number;
  26028. /**
  26029. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  26030. */
  26031. static PointToPointJoint: number;
  26032. /**
  26033. * Spring-Joint type
  26034. */
  26035. static SpringJoint: number;
  26036. /**
  26037. * Lock-Joint type
  26038. */
  26039. static LockJoint: number;
  26040. }
  26041. /**
  26042. * A class representing a physics distance joint
  26043. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26044. */
  26045. export class DistanceJoint extends PhysicsJoint {
  26046. /**
  26047. *
  26048. * @param jointData The data for the Distance-Joint
  26049. */
  26050. constructor(jointData: DistanceJointData);
  26051. /**
  26052. * Update the predefined distance.
  26053. * @param maxDistance The maximum preferred distance
  26054. * @param minDistance The minimum preferred distance
  26055. */
  26056. updateDistance(maxDistance: number, minDistance?: number): void;
  26057. }
  26058. /**
  26059. * Represents a Motor-Enabled Joint
  26060. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26061. */
  26062. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  26063. /**
  26064. * Initializes the Motor-Enabled Joint
  26065. * @param type The type of the joint
  26066. * @param jointData The physica joint data for the joint
  26067. */
  26068. constructor(type: number, jointData: PhysicsJointData);
  26069. /**
  26070. * Set the motor values.
  26071. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26072. * @param force the force to apply
  26073. * @param maxForce max force for this motor.
  26074. */
  26075. setMotor(force?: number, maxForce?: number): void;
  26076. /**
  26077. * Set the motor's limits.
  26078. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26079. * @param upperLimit The upper limit of the motor
  26080. * @param lowerLimit The lower limit of the motor
  26081. */
  26082. setLimit(upperLimit: number, lowerLimit?: number): void;
  26083. }
  26084. /**
  26085. * This class represents a single physics Hinge-Joint
  26086. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26087. */
  26088. export class HingeJoint extends MotorEnabledJoint {
  26089. /**
  26090. * Initializes the Hinge-Joint
  26091. * @param jointData The joint data for the Hinge-Joint
  26092. */
  26093. constructor(jointData: PhysicsJointData);
  26094. /**
  26095. * Set the motor values.
  26096. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26097. * @param {number} force the force to apply
  26098. * @param {number} maxForce max force for this motor.
  26099. */
  26100. setMotor(force?: number, maxForce?: number): void;
  26101. /**
  26102. * Set the motor's limits.
  26103. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26104. * @param upperLimit The upper limit of the motor
  26105. * @param lowerLimit The lower limit of the motor
  26106. */
  26107. setLimit(upperLimit: number, lowerLimit?: number): void;
  26108. }
  26109. /**
  26110. * This class represents a dual hinge physics joint (same as wheel joint)
  26111. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26112. */
  26113. export class Hinge2Joint extends MotorEnabledJoint {
  26114. /**
  26115. * Initializes the Hinge2-Joint
  26116. * @param jointData The joint data for the Hinge2-Joint
  26117. */
  26118. constructor(jointData: PhysicsJointData);
  26119. /**
  26120. * Set the motor values.
  26121. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26122. * @param {number} targetSpeed the speed the motor is to reach
  26123. * @param {number} maxForce max force for this motor.
  26124. * @param {motorIndex} the motor's index, 0 or 1.
  26125. */
  26126. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  26127. /**
  26128. * Set the motor limits.
  26129. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26130. * @param {number} upperLimit the upper limit
  26131. * @param {number} lowerLimit lower limit
  26132. * @param {motorIndex} the motor's index, 0 or 1.
  26133. */
  26134. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26135. }
  26136. /**
  26137. * Interface for a motor enabled joint
  26138. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26139. */
  26140. export interface IMotorEnabledJoint {
  26141. /**
  26142. * Physics joint
  26143. */
  26144. physicsJoint: any;
  26145. /**
  26146. * Sets the motor of the motor-enabled joint
  26147. * @param force The force of the motor
  26148. * @param maxForce The maximum force of the motor
  26149. * @param motorIndex The index of the motor
  26150. */
  26151. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  26152. /**
  26153. * Sets the limit of the motor
  26154. * @param upperLimit The upper limit of the motor
  26155. * @param lowerLimit The lower limit of the motor
  26156. * @param motorIndex The index of the motor
  26157. */
  26158. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26159. }
  26160. /**
  26161. * Joint data for a Distance-Joint
  26162. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26163. */
  26164. export interface DistanceJointData extends PhysicsJointData {
  26165. /**
  26166. * Max distance the 2 joint objects can be apart
  26167. */
  26168. maxDistance: number;
  26169. }
  26170. /**
  26171. * Joint data from a spring joint
  26172. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26173. */
  26174. export interface SpringJointData extends PhysicsJointData {
  26175. /**
  26176. * Length of the spring
  26177. */
  26178. length: number;
  26179. /**
  26180. * Stiffness of the spring
  26181. */
  26182. stiffness: number;
  26183. /**
  26184. * Damping of the spring
  26185. */
  26186. damping: number;
  26187. /** this callback will be called when applying the force to the impostors. */
  26188. forceApplicationCallback: () => void;
  26189. }
  26190. }
  26191. declare module BABYLON {
  26192. /**
  26193. * Holds the data for the raycast result
  26194. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26195. */
  26196. export class PhysicsRaycastResult {
  26197. private _hasHit;
  26198. private _hitDistance;
  26199. private _hitNormalWorld;
  26200. private _hitPointWorld;
  26201. private _rayFromWorld;
  26202. private _rayToWorld;
  26203. /**
  26204. * Gets if there was a hit
  26205. */
  26206. get hasHit(): boolean;
  26207. /**
  26208. * Gets the distance from the hit
  26209. */
  26210. get hitDistance(): number;
  26211. /**
  26212. * Gets the hit normal/direction in the world
  26213. */
  26214. get hitNormalWorld(): Vector3;
  26215. /**
  26216. * Gets the hit point in the world
  26217. */
  26218. get hitPointWorld(): Vector3;
  26219. /**
  26220. * Gets the ray "start point" of the ray in the world
  26221. */
  26222. get rayFromWorld(): Vector3;
  26223. /**
  26224. * Gets the ray "end point" of the ray in the world
  26225. */
  26226. get rayToWorld(): Vector3;
  26227. /**
  26228. * Sets the hit data (normal & point in world space)
  26229. * @param hitNormalWorld defines the normal in world space
  26230. * @param hitPointWorld defines the point in world space
  26231. */
  26232. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  26233. /**
  26234. * Sets the distance from the start point to the hit point
  26235. * @param distance
  26236. */
  26237. setHitDistance(distance: number): void;
  26238. /**
  26239. * Calculates the distance manually
  26240. */
  26241. calculateHitDistance(): void;
  26242. /**
  26243. * Resets all the values to default
  26244. * @param from The from point on world space
  26245. * @param to The to point on world space
  26246. */
  26247. reset(from?: Vector3, to?: Vector3): void;
  26248. }
  26249. /**
  26250. * Interface for the size containing width and height
  26251. */
  26252. interface IXYZ {
  26253. /**
  26254. * X
  26255. */
  26256. x: number;
  26257. /**
  26258. * Y
  26259. */
  26260. y: number;
  26261. /**
  26262. * Z
  26263. */
  26264. z: number;
  26265. }
  26266. }
  26267. declare module BABYLON {
  26268. /**
  26269. * Interface used to describe a physics joint
  26270. */
  26271. export interface PhysicsImpostorJoint {
  26272. /** Defines the main impostor to which the joint is linked */
  26273. mainImpostor: PhysicsImpostor;
  26274. /** Defines the impostor that is connected to the main impostor using this joint */
  26275. connectedImpostor: PhysicsImpostor;
  26276. /** Defines the joint itself */
  26277. joint: PhysicsJoint;
  26278. }
  26279. /** @hidden */
  26280. export interface IPhysicsEnginePlugin {
  26281. world: any;
  26282. name: string;
  26283. setGravity(gravity: Vector3): void;
  26284. setTimeStep(timeStep: number): void;
  26285. getTimeStep(): number;
  26286. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  26287. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26288. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26289. generatePhysicsBody(impostor: PhysicsImpostor): void;
  26290. removePhysicsBody(impostor: PhysicsImpostor): void;
  26291. generateJoint(joint: PhysicsImpostorJoint): void;
  26292. removeJoint(joint: PhysicsImpostorJoint): void;
  26293. isSupported(): boolean;
  26294. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  26295. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  26296. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26297. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26298. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26299. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26300. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  26301. getBodyMass(impostor: PhysicsImpostor): number;
  26302. getBodyFriction(impostor: PhysicsImpostor): number;
  26303. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  26304. getBodyRestitution(impostor: PhysicsImpostor): number;
  26305. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  26306. getBodyPressure?(impostor: PhysicsImpostor): number;
  26307. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  26308. getBodyStiffness?(impostor: PhysicsImpostor): number;
  26309. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  26310. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  26311. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  26312. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  26313. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  26314. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  26315. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  26316. sleepBody(impostor: PhysicsImpostor): void;
  26317. wakeUpBody(impostor: PhysicsImpostor): void;
  26318. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  26319. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  26320. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  26321. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26322. getRadius(impostor: PhysicsImpostor): number;
  26323. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  26324. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  26325. dispose(): void;
  26326. }
  26327. /**
  26328. * Interface used to define a physics engine
  26329. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  26330. */
  26331. export interface IPhysicsEngine {
  26332. /**
  26333. * Gets the gravity vector used by the simulation
  26334. */
  26335. gravity: Vector3;
  26336. /**
  26337. * Sets the gravity vector used by the simulation
  26338. * @param gravity defines the gravity vector to use
  26339. */
  26340. setGravity(gravity: Vector3): void;
  26341. /**
  26342. * Set the time step of the physics engine.
  26343. * Default is 1/60.
  26344. * To slow it down, enter 1/600 for example.
  26345. * To speed it up, 1/30
  26346. * @param newTimeStep the new timestep to apply to this world.
  26347. */
  26348. setTimeStep(newTimeStep: number): void;
  26349. /**
  26350. * Get the time step of the physics engine.
  26351. * @returns the current time step
  26352. */
  26353. getTimeStep(): number;
  26354. /**
  26355. * Set the sub time step of the physics engine.
  26356. * Default is 0 meaning there is no sub steps
  26357. * To increase physics resolution precision, set a small value (like 1 ms)
  26358. * @param subTimeStep defines the new sub timestep used for physics resolution.
  26359. */
  26360. setSubTimeStep(subTimeStep: number): void;
  26361. /**
  26362. * Get the sub time step of the physics engine.
  26363. * @returns the current sub time step
  26364. */
  26365. getSubTimeStep(): number;
  26366. /**
  26367. * Release all resources
  26368. */
  26369. dispose(): void;
  26370. /**
  26371. * Gets the name of the current physics plugin
  26372. * @returns the name of the plugin
  26373. */
  26374. getPhysicsPluginName(): string;
  26375. /**
  26376. * Adding a new impostor for the impostor tracking.
  26377. * This will be done by the impostor itself.
  26378. * @param impostor the impostor to add
  26379. */
  26380. addImpostor(impostor: PhysicsImpostor): void;
  26381. /**
  26382. * Remove an impostor from the engine.
  26383. * This impostor and its mesh will not longer be updated by the physics engine.
  26384. * @param impostor the impostor to remove
  26385. */
  26386. removeImpostor(impostor: PhysicsImpostor): void;
  26387. /**
  26388. * Add a joint to the physics engine
  26389. * @param mainImpostor defines the main impostor to which the joint is added.
  26390. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  26391. * @param joint defines the joint that will connect both impostors.
  26392. */
  26393. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26394. /**
  26395. * Removes a joint from the simulation
  26396. * @param mainImpostor defines the impostor used with the joint
  26397. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  26398. * @param joint defines the joint to remove
  26399. */
  26400. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26401. /**
  26402. * Gets the current plugin used to run the simulation
  26403. * @returns current plugin
  26404. */
  26405. getPhysicsPlugin(): IPhysicsEnginePlugin;
  26406. /**
  26407. * Gets the list of physic impostors
  26408. * @returns an array of PhysicsImpostor
  26409. */
  26410. getImpostors(): Array<PhysicsImpostor>;
  26411. /**
  26412. * Gets the impostor for a physics enabled object
  26413. * @param object defines the object impersonated by the impostor
  26414. * @returns the PhysicsImpostor or null if not found
  26415. */
  26416. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  26417. /**
  26418. * Gets the impostor for a physics body object
  26419. * @param body defines physics body used by the impostor
  26420. * @returns the PhysicsImpostor or null if not found
  26421. */
  26422. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  26423. /**
  26424. * Does a raycast in the physics world
  26425. * @param from when should the ray start?
  26426. * @param to when should the ray end?
  26427. * @returns PhysicsRaycastResult
  26428. */
  26429. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  26430. /**
  26431. * Called by the scene. No need to call it.
  26432. * @param delta defines the timespam between frames
  26433. */
  26434. _step(delta: number): void;
  26435. }
  26436. }
  26437. declare module BABYLON {
  26438. /**
  26439. * The interface for the physics imposter parameters
  26440. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26441. */
  26442. export interface PhysicsImpostorParameters {
  26443. /**
  26444. * The mass of the physics imposter
  26445. */
  26446. mass: number;
  26447. /**
  26448. * The friction of the physics imposter
  26449. */
  26450. friction?: number;
  26451. /**
  26452. * The coefficient of restitution of the physics imposter
  26453. */
  26454. restitution?: number;
  26455. /**
  26456. * The native options of the physics imposter
  26457. */
  26458. nativeOptions?: any;
  26459. /**
  26460. * Specifies if the parent should be ignored
  26461. */
  26462. ignoreParent?: boolean;
  26463. /**
  26464. * Specifies if bi-directional transformations should be disabled
  26465. */
  26466. disableBidirectionalTransformation?: boolean;
  26467. /**
  26468. * The pressure inside the physics imposter, soft object only
  26469. */
  26470. pressure?: number;
  26471. /**
  26472. * The stiffness the physics imposter, soft object only
  26473. */
  26474. stiffness?: number;
  26475. /**
  26476. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  26477. */
  26478. velocityIterations?: number;
  26479. /**
  26480. * The number of iterations used in maintaining consistent vertex positions, soft object only
  26481. */
  26482. positionIterations?: number;
  26483. /**
  26484. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  26485. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  26486. * Add to fix multiple points
  26487. */
  26488. fixedPoints?: number;
  26489. /**
  26490. * The collision margin around a soft object
  26491. */
  26492. margin?: number;
  26493. /**
  26494. * The collision margin around a soft object
  26495. */
  26496. damping?: number;
  26497. /**
  26498. * The path for a rope based on an extrusion
  26499. */
  26500. path?: any;
  26501. /**
  26502. * The shape of an extrusion used for a rope based on an extrusion
  26503. */
  26504. shape?: any;
  26505. }
  26506. /**
  26507. * Interface for a physics-enabled object
  26508. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26509. */
  26510. export interface IPhysicsEnabledObject {
  26511. /**
  26512. * The position of the physics-enabled object
  26513. */
  26514. position: Vector3;
  26515. /**
  26516. * The rotation of the physics-enabled object
  26517. */
  26518. rotationQuaternion: Nullable<Quaternion>;
  26519. /**
  26520. * The scale of the physics-enabled object
  26521. */
  26522. scaling: Vector3;
  26523. /**
  26524. * The rotation of the physics-enabled object
  26525. */
  26526. rotation?: Vector3;
  26527. /**
  26528. * The parent of the physics-enabled object
  26529. */
  26530. parent?: any;
  26531. /**
  26532. * The bounding info of the physics-enabled object
  26533. * @returns The bounding info of the physics-enabled object
  26534. */
  26535. getBoundingInfo(): BoundingInfo;
  26536. /**
  26537. * Computes the world matrix
  26538. * @param force Specifies if the world matrix should be computed by force
  26539. * @returns A world matrix
  26540. */
  26541. computeWorldMatrix(force: boolean): Matrix;
  26542. /**
  26543. * Gets the world matrix
  26544. * @returns A world matrix
  26545. */
  26546. getWorldMatrix?(): Matrix;
  26547. /**
  26548. * Gets the child meshes
  26549. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  26550. * @returns An array of abstract meshes
  26551. */
  26552. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  26553. /**
  26554. * Gets the vertex data
  26555. * @param kind The type of vertex data
  26556. * @returns A nullable array of numbers, or a float32 array
  26557. */
  26558. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  26559. /**
  26560. * Gets the indices from the mesh
  26561. * @returns A nullable array of index arrays
  26562. */
  26563. getIndices?(): Nullable<IndicesArray>;
  26564. /**
  26565. * Gets the scene from the mesh
  26566. * @returns the indices array or null
  26567. */
  26568. getScene?(): Scene;
  26569. /**
  26570. * Gets the absolute position from the mesh
  26571. * @returns the absolute position
  26572. */
  26573. getAbsolutePosition(): Vector3;
  26574. /**
  26575. * Gets the absolute pivot point from the mesh
  26576. * @returns the absolute pivot point
  26577. */
  26578. getAbsolutePivotPoint(): Vector3;
  26579. /**
  26580. * Rotates the mesh
  26581. * @param axis The axis of rotation
  26582. * @param amount The amount of rotation
  26583. * @param space The space of the rotation
  26584. * @returns The rotation transform node
  26585. */
  26586. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26587. /**
  26588. * Translates the mesh
  26589. * @param axis The axis of translation
  26590. * @param distance The distance of translation
  26591. * @param space The space of the translation
  26592. * @returns The transform node
  26593. */
  26594. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26595. /**
  26596. * Sets the absolute position of the mesh
  26597. * @param absolutePosition The absolute position of the mesh
  26598. * @returns The transform node
  26599. */
  26600. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26601. /**
  26602. * Gets the class name of the mesh
  26603. * @returns The class name
  26604. */
  26605. getClassName(): string;
  26606. }
  26607. /**
  26608. * Represents a physics imposter
  26609. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26610. */
  26611. export class PhysicsImpostor {
  26612. /**
  26613. * The physics-enabled object used as the physics imposter
  26614. */
  26615. object: IPhysicsEnabledObject;
  26616. /**
  26617. * The type of the physics imposter
  26618. */
  26619. type: number;
  26620. private _options;
  26621. private _scene?;
  26622. /**
  26623. * The default object size of the imposter
  26624. */
  26625. static DEFAULT_OBJECT_SIZE: Vector3;
  26626. /**
  26627. * The identity quaternion of the imposter
  26628. */
  26629. static IDENTITY_QUATERNION: Quaternion;
  26630. /** @hidden */
  26631. _pluginData: any;
  26632. private _physicsEngine;
  26633. private _physicsBody;
  26634. private _bodyUpdateRequired;
  26635. private _onBeforePhysicsStepCallbacks;
  26636. private _onAfterPhysicsStepCallbacks;
  26637. /** @hidden */
  26638. _onPhysicsCollideCallbacks: Array<{
  26639. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  26640. otherImpostors: Array<PhysicsImpostor>;
  26641. }>;
  26642. private _deltaPosition;
  26643. private _deltaRotation;
  26644. private _deltaRotationConjugated;
  26645. /** @hidden */
  26646. _isFromLine: boolean;
  26647. private _parent;
  26648. private _isDisposed;
  26649. private static _tmpVecs;
  26650. private static _tmpQuat;
  26651. /**
  26652. * Specifies if the physics imposter is disposed
  26653. */
  26654. get isDisposed(): boolean;
  26655. /**
  26656. * Gets the mass of the physics imposter
  26657. */
  26658. get mass(): number;
  26659. set mass(value: number);
  26660. /**
  26661. * Gets the coefficient of friction
  26662. */
  26663. get friction(): number;
  26664. /**
  26665. * Sets the coefficient of friction
  26666. */
  26667. set friction(value: number);
  26668. /**
  26669. * Gets the coefficient of restitution
  26670. */
  26671. get restitution(): number;
  26672. /**
  26673. * Sets the coefficient of restitution
  26674. */
  26675. set restitution(value: number);
  26676. /**
  26677. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  26678. */
  26679. get pressure(): number;
  26680. /**
  26681. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  26682. */
  26683. set pressure(value: number);
  26684. /**
  26685. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  26686. */
  26687. get stiffness(): number;
  26688. /**
  26689. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  26690. */
  26691. set stiffness(value: number);
  26692. /**
  26693. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  26694. */
  26695. get velocityIterations(): number;
  26696. /**
  26697. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  26698. */
  26699. set velocityIterations(value: number);
  26700. /**
  26701. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  26702. */
  26703. get positionIterations(): number;
  26704. /**
  26705. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  26706. */
  26707. set positionIterations(value: number);
  26708. /**
  26709. * The unique id of the physics imposter
  26710. * set by the physics engine when adding this impostor to the array
  26711. */
  26712. uniqueId: number;
  26713. /**
  26714. * @hidden
  26715. */
  26716. soft: boolean;
  26717. /**
  26718. * @hidden
  26719. */
  26720. segments: number;
  26721. private _joints;
  26722. /**
  26723. * Initializes the physics imposter
  26724. * @param object The physics-enabled object used as the physics imposter
  26725. * @param type The type of the physics imposter
  26726. * @param _options The options for the physics imposter
  26727. * @param _scene The Babylon scene
  26728. */
  26729. constructor(
  26730. /**
  26731. * The physics-enabled object used as the physics imposter
  26732. */
  26733. object: IPhysicsEnabledObject,
  26734. /**
  26735. * The type of the physics imposter
  26736. */
  26737. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  26738. /**
  26739. * This function will completly initialize this impostor.
  26740. * It will create a new body - but only if this mesh has no parent.
  26741. * If it has, this impostor will not be used other than to define the impostor
  26742. * of the child mesh.
  26743. * @hidden
  26744. */
  26745. _init(): void;
  26746. private _getPhysicsParent;
  26747. /**
  26748. * Should a new body be generated.
  26749. * @returns boolean specifying if body initialization is required
  26750. */
  26751. isBodyInitRequired(): boolean;
  26752. /**
  26753. * Sets the updated scaling
  26754. * @param updated Specifies if the scaling is updated
  26755. */
  26756. setScalingUpdated(): void;
  26757. /**
  26758. * Force a regeneration of this or the parent's impostor's body.
  26759. * Use under cautious - This will remove all joints already implemented.
  26760. */
  26761. forceUpdate(): void;
  26762. /**
  26763. * Gets the body that holds this impostor. Either its own, or its parent.
  26764. */
  26765. get physicsBody(): any;
  26766. /**
  26767. * Get the parent of the physics imposter
  26768. * @returns Physics imposter or null
  26769. */
  26770. get parent(): Nullable<PhysicsImpostor>;
  26771. /**
  26772. * Sets the parent of the physics imposter
  26773. */
  26774. set parent(value: Nullable<PhysicsImpostor>);
  26775. /**
  26776. * Set the physics body. Used mainly by the physics engine/plugin
  26777. */
  26778. set physicsBody(physicsBody: any);
  26779. /**
  26780. * Resets the update flags
  26781. */
  26782. resetUpdateFlags(): void;
  26783. /**
  26784. * Gets the object extend size
  26785. * @returns the object extend size
  26786. */
  26787. getObjectExtendSize(): Vector3;
  26788. /**
  26789. * Gets the object center
  26790. * @returns The object center
  26791. */
  26792. getObjectCenter(): Vector3;
  26793. /**
  26794. * Get a specific parameter from the options parameters
  26795. * @param paramName The object parameter name
  26796. * @returns The object parameter
  26797. */
  26798. getParam(paramName: string): any;
  26799. /**
  26800. * Sets a specific parameter in the options given to the physics plugin
  26801. * @param paramName The parameter name
  26802. * @param value The value of the parameter
  26803. */
  26804. setParam(paramName: string, value: number): void;
  26805. /**
  26806. * Specifically change the body's mass option. Won't recreate the physics body object
  26807. * @param mass The mass of the physics imposter
  26808. */
  26809. setMass(mass: number): void;
  26810. /**
  26811. * Gets the linear velocity
  26812. * @returns linear velocity or null
  26813. */
  26814. getLinearVelocity(): Nullable<Vector3>;
  26815. /**
  26816. * Sets the linear velocity
  26817. * @param velocity linear velocity or null
  26818. */
  26819. setLinearVelocity(velocity: Nullable<Vector3>): void;
  26820. /**
  26821. * Gets the angular velocity
  26822. * @returns angular velocity or null
  26823. */
  26824. getAngularVelocity(): Nullable<Vector3>;
  26825. /**
  26826. * Sets the angular velocity
  26827. * @param velocity The velocity or null
  26828. */
  26829. setAngularVelocity(velocity: Nullable<Vector3>): void;
  26830. /**
  26831. * Execute a function with the physics plugin native code
  26832. * Provide a function the will have two variables - the world object and the physics body object
  26833. * @param func The function to execute with the physics plugin native code
  26834. */
  26835. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  26836. /**
  26837. * Register a function that will be executed before the physics world is stepping forward
  26838. * @param func The function to execute before the physics world is stepped forward
  26839. */
  26840. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26841. /**
  26842. * Unregister a function that will be executed before the physics world is stepping forward
  26843. * @param func The function to execute before the physics world is stepped forward
  26844. */
  26845. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26846. /**
  26847. * Register a function that will be executed after the physics step
  26848. * @param func The function to execute after physics step
  26849. */
  26850. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26851. /**
  26852. * Unregisters a function that will be executed after the physics step
  26853. * @param func The function to execute after physics step
  26854. */
  26855. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26856. /**
  26857. * register a function that will be executed when this impostor collides against a different body
  26858. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  26859. * @param func Callback that is executed on collision
  26860. */
  26861. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  26862. /**
  26863. * Unregisters the physics imposter on contact
  26864. * @param collideAgainst The physics object to collide against
  26865. * @param func Callback to execute on collision
  26866. */
  26867. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  26868. private _tmpQuat;
  26869. private _tmpQuat2;
  26870. /**
  26871. * Get the parent rotation
  26872. * @returns The parent rotation
  26873. */
  26874. getParentsRotation(): Quaternion;
  26875. /**
  26876. * this function is executed by the physics engine.
  26877. */
  26878. beforeStep: () => void;
  26879. /**
  26880. * this function is executed by the physics engine
  26881. */
  26882. afterStep: () => void;
  26883. /**
  26884. * Legacy collision detection event support
  26885. */
  26886. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  26887. /**
  26888. * event and body object due to cannon's event-based architecture.
  26889. */
  26890. onCollide: (e: {
  26891. body: any;
  26892. }) => void;
  26893. /**
  26894. * Apply a force
  26895. * @param force The force to apply
  26896. * @param contactPoint The contact point for the force
  26897. * @returns The physics imposter
  26898. */
  26899. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  26900. /**
  26901. * Apply an impulse
  26902. * @param force The impulse force
  26903. * @param contactPoint The contact point for the impulse force
  26904. * @returns The physics imposter
  26905. */
  26906. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  26907. /**
  26908. * A help function to create a joint
  26909. * @param otherImpostor A physics imposter used to create a joint
  26910. * @param jointType The type of joint
  26911. * @param jointData The data for the joint
  26912. * @returns The physics imposter
  26913. */
  26914. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  26915. /**
  26916. * Add a joint to this impostor with a different impostor
  26917. * @param otherImpostor A physics imposter used to add a joint
  26918. * @param joint The joint to add
  26919. * @returns The physics imposter
  26920. */
  26921. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  26922. /**
  26923. * Add an anchor to a cloth impostor
  26924. * @param otherImpostor rigid impostor to anchor to
  26925. * @param width ratio across width from 0 to 1
  26926. * @param height ratio up height from 0 to 1
  26927. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  26928. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  26929. * @returns impostor the soft imposter
  26930. */
  26931. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  26932. /**
  26933. * Add a hook to a rope impostor
  26934. * @param otherImpostor rigid impostor to anchor to
  26935. * @param length ratio across rope from 0 to 1
  26936. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  26937. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  26938. * @returns impostor the rope imposter
  26939. */
  26940. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  26941. /**
  26942. * Will keep this body still, in a sleep mode.
  26943. * @returns the physics imposter
  26944. */
  26945. sleep(): PhysicsImpostor;
  26946. /**
  26947. * Wake the body up.
  26948. * @returns The physics imposter
  26949. */
  26950. wakeUp(): PhysicsImpostor;
  26951. /**
  26952. * Clones the physics imposter
  26953. * @param newObject The physics imposter clones to this physics-enabled object
  26954. * @returns A nullable physics imposter
  26955. */
  26956. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  26957. /**
  26958. * Disposes the physics imposter
  26959. */
  26960. dispose(): void;
  26961. /**
  26962. * Sets the delta position
  26963. * @param position The delta position amount
  26964. */
  26965. setDeltaPosition(position: Vector3): void;
  26966. /**
  26967. * Sets the delta rotation
  26968. * @param rotation The delta rotation amount
  26969. */
  26970. setDeltaRotation(rotation: Quaternion): void;
  26971. /**
  26972. * Gets the box size of the physics imposter and stores the result in the input parameter
  26973. * @param result Stores the box size
  26974. * @returns The physics imposter
  26975. */
  26976. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  26977. /**
  26978. * Gets the radius of the physics imposter
  26979. * @returns Radius of the physics imposter
  26980. */
  26981. getRadius(): number;
  26982. /**
  26983. * Sync a bone with this impostor
  26984. * @param bone The bone to sync to the impostor.
  26985. * @param boneMesh The mesh that the bone is influencing.
  26986. * @param jointPivot The pivot of the joint / bone in local space.
  26987. * @param distToJoint Optional distance from the impostor to the joint.
  26988. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  26989. */
  26990. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  26991. /**
  26992. * Sync impostor to a bone
  26993. * @param bone The bone that the impostor will be synced to.
  26994. * @param boneMesh The mesh that the bone is influencing.
  26995. * @param jointPivot The pivot of the joint / bone in local space.
  26996. * @param distToJoint Optional distance from the impostor to the joint.
  26997. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  26998. * @param boneAxis Optional vector3 axis the bone is aligned with
  26999. */
  27000. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  27001. /**
  27002. * No-Imposter type
  27003. */
  27004. static NoImpostor: number;
  27005. /**
  27006. * Sphere-Imposter type
  27007. */
  27008. static SphereImpostor: number;
  27009. /**
  27010. * Box-Imposter type
  27011. */
  27012. static BoxImpostor: number;
  27013. /**
  27014. * Plane-Imposter type
  27015. */
  27016. static PlaneImpostor: number;
  27017. /**
  27018. * Mesh-imposter type
  27019. */
  27020. static MeshImpostor: number;
  27021. /**
  27022. * Capsule-Impostor type (Ammo.js plugin only)
  27023. */
  27024. static CapsuleImpostor: number;
  27025. /**
  27026. * Cylinder-Imposter type
  27027. */
  27028. static CylinderImpostor: number;
  27029. /**
  27030. * Particle-Imposter type
  27031. */
  27032. static ParticleImpostor: number;
  27033. /**
  27034. * Heightmap-Imposter type
  27035. */
  27036. static HeightmapImpostor: number;
  27037. /**
  27038. * ConvexHull-Impostor type (Ammo.js plugin only)
  27039. */
  27040. static ConvexHullImpostor: number;
  27041. /**
  27042. * Custom-Imposter type (Ammo.js plugin only)
  27043. */
  27044. static CustomImpostor: number;
  27045. /**
  27046. * Rope-Imposter type
  27047. */
  27048. static RopeImpostor: number;
  27049. /**
  27050. * Cloth-Imposter type
  27051. */
  27052. static ClothImpostor: number;
  27053. /**
  27054. * Softbody-Imposter type
  27055. */
  27056. static SoftbodyImpostor: number;
  27057. }
  27058. }
  27059. declare module BABYLON {
  27060. /**
  27061. * @hidden
  27062. **/
  27063. export class _CreationDataStorage {
  27064. closePath?: boolean;
  27065. closeArray?: boolean;
  27066. idx: number[];
  27067. dashSize: number;
  27068. gapSize: number;
  27069. path3D: Path3D;
  27070. pathArray: Vector3[][];
  27071. arc: number;
  27072. radius: number;
  27073. cap: number;
  27074. tessellation: number;
  27075. }
  27076. /**
  27077. * @hidden
  27078. **/
  27079. class _InstanceDataStorage {
  27080. visibleInstances: any;
  27081. batchCache: _InstancesBatch;
  27082. instancesBufferSize: number;
  27083. instancesBuffer: Nullable<Buffer>;
  27084. instancesData: Float32Array;
  27085. overridenInstanceCount: number;
  27086. isFrozen: boolean;
  27087. previousBatch: Nullable<_InstancesBatch>;
  27088. hardwareInstancedRendering: boolean;
  27089. sideOrientation: number;
  27090. manualUpdate: boolean;
  27091. }
  27092. /**
  27093. * @hidden
  27094. **/
  27095. export class _InstancesBatch {
  27096. mustReturn: boolean;
  27097. visibleInstances: Nullable<InstancedMesh[]>[];
  27098. renderSelf: boolean[];
  27099. hardwareInstancedRendering: boolean[];
  27100. }
  27101. /**
  27102. * Class used to represent renderable models
  27103. */
  27104. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  27105. /**
  27106. * Mesh side orientation : usually the external or front surface
  27107. */
  27108. static readonly FRONTSIDE: number;
  27109. /**
  27110. * Mesh side orientation : usually the internal or back surface
  27111. */
  27112. static readonly BACKSIDE: number;
  27113. /**
  27114. * Mesh side orientation : both internal and external or front and back surfaces
  27115. */
  27116. static readonly DOUBLESIDE: number;
  27117. /**
  27118. * Mesh side orientation : by default, `FRONTSIDE`
  27119. */
  27120. static readonly DEFAULTSIDE: number;
  27121. /**
  27122. * Mesh cap setting : no cap
  27123. */
  27124. static readonly NO_CAP: number;
  27125. /**
  27126. * Mesh cap setting : one cap at the beginning of the mesh
  27127. */
  27128. static readonly CAP_START: number;
  27129. /**
  27130. * Mesh cap setting : one cap at the end of the mesh
  27131. */
  27132. static readonly CAP_END: number;
  27133. /**
  27134. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  27135. */
  27136. static readonly CAP_ALL: number;
  27137. /**
  27138. * Mesh pattern setting : no flip or rotate
  27139. */
  27140. static readonly NO_FLIP: number;
  27141. /**
  27142. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  27143. */
  27144. static readonly FLIP_TILE: number;
  27145. /**
  27146. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  27147. */
  27148. static readonly ROTATE_TILE: number;
  27149. /**
  27150. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  27151. */
  27152. static readonly FLIP_ROW: number;
  27153. /**
  27154. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  27155. */
  27156. static readonly ROTATE_ROW: number;
  27157. /**
  27158. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  27159. */
  27160. static readonly FLIP_N_ROTATE_TILE: number;
  27161. /**
  27162. * Mesh pattern setting : rotate pattern and rotate
  27163. */
  27164. static readonly FLIP_N_ROTATE_ROW: number;
  27165. /**
  27166. * Mesh tile positioning : part tiles same on left/right or top/bottom
  27167. */
  27168. static readonly CENTER: number;
  27169. /**
  27170. * Mesh tile positioning : part tiles on left
  27171. */
  27172. static readonly LEFT: number;
  27173. /**
  27174. * Mesh tile positioning : part tiles on right
  27175. */
  27176. static readonly RIGHT: number;
  27177. /**
  27178. * Mesh tile positioning : part tiles on top
  27179. */
  27180. static readonly TOP: number;
  27181. /**
  27182. * Mesh tile positioning : part tiles on bottom
  27183. */
  27184. static readonly BOTTOM: number;
  27185. /**
  27186. * Gets the default side orientation.
  27187. * @param orientation the orientation to value to attempt to get
  27188. * @returns the default orientation
  27189. * @hidden
  27190. */
  27191. static _GetDefaultSideOrientation(orientation?: number): number;
  27192. private _internalMeshDataInfo;
  27193. /**
  27194. * An event triggered before rendering the mesh
  27195. */
  27196. get onBeforeRenderObservable(): Observable<Mesh>;
  27197. /**
  27198. * An event triggered before binding the mesh
  27199. */
  27200. get onBeforeBindObservable(): Observable<Mesh>;
  27201. /**
  27202. * An event triggered after rendering the mesh
  27203. */
  27204. get onAfterRenderObservable(): Observable<Mesh>;
  27205. /**
  27206. * An event triggered before drawing the mesh
  27207. */
  27208. get onBeforeDrawObservable(): Observable<Mesh>;
  27209. private _onBeforeDrawObserver;
  27210. /**
  27211. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  27212. */
  27213. set onBeforeDraw(callback: () => void);
  27214. get hasInstances(): boolean;
  27215. /**
  27216. * Gets the delay loading state of the mesh (when delay loading is turned on)
  27217. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  27218. */
  27219. delayLoadState: number;
  27220. /**
  27221. * Gets the list of instances created from this mesh
  27222. * it is not supposed to be modified manually.
  27223. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  27224. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27225. */
  27226. instances: InstancedMesh[];
  27227. /**
  27228. * Gets the file containing delay loading data for this mesh
  27229. */
  27230. delayLoadingFile: string;
  27231. /** @hidden */
  27232. _binaryInfo: any;
  27233. /**
  27234. * User defined function used to change how LOD level selection is done
  27235. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  27236. */
  27237. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  27238. /**
  27239. * Gets or sets the morph target manager
  27240. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27241. */
  27242. get morphTargetManager(): Nullable<MorphTargetManager>;
  27243. set morphTargetManager(value: Nullable<MorphTargetManager>);
  27244. /** @hidden */
  27245. _creationDataStorage: Nullable<_CreationDataStorage>;
  27246. /** @hidden */
  27247. _geometry: Nullable<Geometry>;
  27248. /** @hidden */
  27249. _delayInfo: Array<string>;
  27250. /** @hidden */
  27251. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  27252. /** @hidden */
  27253. _instanceDataStorage: _InstanceDataStorage;
  27254. private _effectiveMaterial;
  27255. /** @hidden */
  27256. _shouldGenerateFlatShading: boolean;
  27257. /** @hidden */
  27258. _originalBuilderSideOrientation: number;
  27259. /**
  27260. * Use this property to change the original side orientation defined at construction time
  27261. */
  27262. overrideMaterialSideOrientation: Nullable<number>;
  27263. /**
  27264. * Gets the source mesh (the one used to clone this one from)
  27265. */
  27266. get source(): Nullable<Mesh>;
  27267. /**
  27268. * Gets or sets a boolean indicating that this mesh does not use index buffer
  27269. */
  27270. get isUnIndexed(): boolean;
  27271. set isUnIndexed(value: boolean);
  27272. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  27273. get worldMatrixInstancedBuffer(): Float32Array;
  27274. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  27275. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  27276. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  27277. /**
  27278. * @constructor
  27279. * @param name The value used by scene.getMeshByName() to do a lookup.
  27280. * @param scene The scene to add this mesh to.
  27281. * @param parent The parent of this mesh, if it has one
  27282. * @param source An optional Mesh from which geometry is shared, cloned.
  27283. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  27284. * When false, achieved by calling a clone(), also passing False.
  27285. * This will make creation of children, recursive.
  27286. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  27287. */
  27288. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  27289. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  27290. doNotInstantiate: boolean;
  27291. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  27292. /**
  27293. * Gets the class name
  27294. * @returns the string "Mesh".
  27295. */
  27296. getClassName(): string;
  27297. /** @hidden */
  27298. get _isMesh(): boolean;
  27299. /**
  27300. * Returns a description of this mesh
  27301. * @param fullDetails define if full details about this mesh must be used
  27302. * @returns a descriptive string representing this mesh
  27303. */
  27304. toString(fullDetails?: boolean): string;
  27305. /** @hidden */
  27306. _unBindEffect(): void;
  27307. /**
  27308. * Gets a boolean indicating if this mesh has LOD
  27309. */
  27310. get hasLODLevels(): boolean;
  27311. /**
  27312. * Gets the list of MeshLODLevel associated with the current mesh
  27313. * @returns an array of MeshLODLevel
  27314. */
  27315. getLODLevels(): MeshLODLevel[];
  27316. private _sortLODLevels;
  27317. /**
  27318. * Add a mesh as LOD level triggered at the given distance.
  27319. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27320. * @param distance The distance from the center of the object to show this level
  27321. * @param mesh The mesh to be added as LOD level (can be null)
  27322. * @return This mesh (for chaining)
  27323. */
  27324. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  27325. /**
  27326. * Returns the LOD level mesh at the passed distance or null if not found.
  27327. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27328. * @param distance The distance from the center of the object to show this level
  27329. * @returns a Mesh or `null`
  27330. */
  27331. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  27332. /**
  27333. * Remove a mesh from the LOD array
  27334. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27335. * @param mesh defines the mesh to be removed
  27336. * @return This mesh (for chaining)
  27337. */
  27338. removeLODLevel(mesh: Mesh): Mesh;
  27339. /**
  27340. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  27341. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27342. * @param camera defines the camera to use to compute distance
  27343. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  27344. * @return This mesh (for chaining)
  27345. */
  27346. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  27347. /**
  27348. * Gets the mesh internal Geometry object
  27349. */
  27350. get geometry(): Nullable<Geometry>;
  27351. /**
  27352. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  27353. * @returns the total number of vertices
  27354. */
  27355. getTotalVertices(): number;
  27356. /**
  27357. * Returns the content of an associated vertex buffer
  27358. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27359. * - VertexBuffer.PositionKind
  27360. * - VertexBuffer.UVKind
  27361. * - VertexBuffer.UV2Kind
  27362. * - VertexBuffer.UV3Kind
  27363. * - VertexBuffer.UV4Kind
  27364. * - VertexBuffer.UV5Kind
  27365. * - VertexBuffer.UV6Kind
  27366. * - VertexBuffer.ColorKind
  27367. * - VertexBuffer.MatricesIndicesKind
  27368. * - VertexBuffer.MatricesIndicesExtraKind
  27369. * - VertexBuffer.MatricesWeightsKind
  27370. * - VertexBuffer.MatricesWeightsExtraKind
  27371. * @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
  27372. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  27373. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  27374. */
  27375. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27376. /**
  27377. * Returns the mesh VertexBuffer object from the requested `kind`
  27378. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27379. * - VertexBuffer.PositionKind
  27380. * - VertexBuffer.NormalKind
  27381. * - VertexBuffer.UVKind
  27382. * - VertexBuffer.UV2Kind
  27383. * - VertexBuffer.UV3Kind
  27384. * - VertexBuffer.UV4Kind
  27385. * - VertexBuffer.UV5Kind
  27386. * - VertexBuffer.UV6Kind
  27387. * - VertexBuffer.ColorKind
  27388. * - VertexBuffer.MatricesIndicesKind
  27389. * - VertexBuffer.MatricesIndicesExtraKind
  27390. * - VertexBuffer.MatricesWeightsKind
  27391. * - VertexBuffer.MatricesWeightsExtraKind
  27392. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  27393. */
  27394. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  27395. /**
  27396. * Tests if a specific vertex buffer is associated with this mesh
  27397. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27398. * - VertexBuffer.PositionKind
  27399. * - VertexBuffer.NormalKind
  27400. * - VertexBuffer.UVKind
  27401. * - VertexBuffer.UV2Kind
  27402. * - VertexBuffer.UV3Kind
  27403. * - VertexBuffer.UV4Kind
  27404. * - VertexBuffer.UV5Kind
  27405. * - VertexBuffer.UV6Kind
  27406. * - VertexBuffer.ColorKind
  27407. * - VertexBuffer.MatricesIndicesKind
  27408. * - VertexBuffer.MatricesIndicesExtraKind
  27409. * - VertexBuffer.MatricesWeightsKind
  27410. * - VertexBuffer.MatricesWeightsExtraKind
  27411. * @returns a boolean
  27412. */
  27413. isVerticesDataPresent(kind: string): boolean;
  27414. /**
  27415. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  27416. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27417. * - VertexBuffer.PositionKind
  27418. * - VertexBuffer.UVKind
  27419. * - VertexBuffer.UV2Kind
  27420. * - VertexBuffer.UV3Kind
  27421. * - VertexBuffer.UV4Kind
  27422. * - VertexBuffer.UV5Kind
  27423. * - VertexBuffer.UV6Kind
  27424. * - VertexBuffer.ColorKind
  27425. * - VertexBuffer.MatricesIndicesKind
  27426. * - VertexBuffer.MatricesIndicesExtraKind
  27427. * - VertexBuffer.MatricesWeightsKind
  27428. * - VertexBuffer.MatricesWeightsExtraKind
  27429. * @returns a boolean
  27430. */
  27431. isVertexBufferUpdatable(kind: string): boolean;
  27432. /**
  27433. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  27434. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27435. * - VertexBuffer.PositionKind
  27436. * - VertexBuffer.NormalKind
  27437. * - VertexBuffer.UVKind
  27438. * - VertexBuffer.UV2Kind
  27439. * - VertexBuffer.UV3Kind
  27440. * - VertexBuffer.UV4Kind
  27441. * - VertexBuffer.UV5Kind
  27442. * - VertexBuffer.UV6Kind
  27443. * - VertexBuffer.ColorKind
  27444. * - VertexBuffer.MatricesIndicesKind
  27445. * - VertexBuffer.MatricesIndicesExtraKind
  27446. * - VertexBuffer.MatricesWeightsKind
  27447. * - VertexBuffer.MatricesWeightsExtraKind
  27448. * @returns an array of strings
  27449. */
  27450. getVerticesDataKinds(): string[];
  27451. /**
  27452. * Returns a positive integer : the total number of indices in this mesh geometry.
  27453. * @returns the numner of indices or zero if the mesh has no geometry.
  27454. */
  27455. getTotalIndices(): number;
  27456. /**
  27457. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27458. * @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.
  27459. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27460. * @returns the indices array or an empty array if the mesh has no geometry
  27461. */
  27462. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27463. get isBlocked(): boolean;
  27464. /**
  27465. * Determine if the current mesh is ready to be rendered
  27466. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27467. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  27468. * @returns true if all associated assets are ready (material, textures, shaders)
  27469. */
  27470. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  27471. /**
  27472. * 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.
  27473. */
  27474. get areNormalsFrozen(): boolean;
  27475. /**
  27476. * 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.
  27477. * @returns the current mesh
  27478. */
  27479. freezeNormals(): Mesh;
  27480. /**
  27481. * 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
  27482. * @returns the current mesh
  27483. */
  27484. unfreezeNormals(): Mesh;
  27485. /**
  27486. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  27487. */
  27488. set overridenInstanceCount(count: number);
  27489. /** @hidden */
  27490. _preActivate(): Mesh;
  27491. /** @hidden */
  27492. _preActivateForIntermediateRendering(renderId: number): Mesh;
  27493. /** @hidden */
  27494. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  27495. /**
  27496. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27497. * This means the mesh underlying bounding box and sphere are recomputed.
  27498. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27499. * @returns the current mesh
  27500. */
  27501. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  27502. /** @hidden */
  27503. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  27504. /**
  27505. * This function will subdivide the mesh into multiple submeshes
  27506. * @param count defines the expected number of submeshes
  27507. */
  27508. subdivide(count: number): void;
  27509. /**
  27510. * Copy a FloatArray into a specific associated vertex buffer
  27511. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27512. * - VertexBuffer.PositionKind
  27513. * - VertexBuffer.UVKind
  27514. * - VertexBuffer.UV2Kind
  27515. * - VertexBuffer.UV3Kind
  27516. * - VertexBuffer.UV4Kind
  27517. * - VertexBuffer.UV5Kind
  27518. * - VertexBuffer.UV6Kind
  27519. * - VertexBuffer.ColorKind
  27520. * - VertexBuffer.MatricesIndicesKind
  27521. * - VertexBuffer.MatricesIndicesExtraKind
  27522. * - VertexBuffer.MatricesWeightsKind
  27523. * - VertexBuffer.MatricesWeightsExtraKind
  27524. * @param data defines the data source
  27525. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27526. * @param stride defines the data stride size (can be null)
  27527. * @returns the current mesh
  27528. */
  27529. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27530. /**
  27531. * Delete a vertex buffer associated with this mesh
  27532. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  27533. * - VertexBuffer.PositionKind
  27534. * - VertexBuffer.UVKind
  27535. * - VertexBuffer.UV2Kind
  27536. * - VertexBuffer.UV3Kind
  27537. * - VertexBuffer.UV4Kind
  27538. * - VertexBuffer.UV5Kind
  27539. * - VertexBuffer.UV6Kind
  27540. * - VertexBuffer.ColorKind
  27541. * - VertexBuffer.MatricesIndicesKind
  27542. * - VertexBuffer.MatricesIndicesExtraKind
  27543. * - VertexBuffer.MatricesWeightsKind
  27544. * - VertexBuffer.MatricesWeightsExtraKind
  27545. */
  27546. removeVerticesData(kind: string): void;
  27547. /**
  27548. * Flags an associated vertex buffer as updatable
  27549. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  27550. * - VertexBuffer.PositionKind
  27551. * - VertexBuffer.UVKind
  27552. * - VertexBuffer.UV2Kind
  27553. * - VertexBuffer.UV3Kind
  27554. * - VertexBuffer.UV4Kind
  27555. * - VertexBuffer.UV5Kind
  27556. * - VertexBuffer.UV6Kind
  27557. * - VertexBuffer.ColorKind
  27558. * - VertexBuffer.MatricesIndicesKind
  27559. * - VertexBuffer.MatricesIndicesExtraKind
  27560. * - VertexBuffer.MatricesWeightsKind
  27561. * - VertexBuffer.MatricesWeightsExtraKind
  27562. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27563. */
  27564. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  27565. /**
  27566. * Sets the mesh global Vertex Buffer
  27567. * @param buffer defines the buffer to use
  27568. * @returns the current mesh
  27569. */
  27570. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  27571. /**
  27572. * Update a specific associated vertex buffer
  27573. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27574. * - VertexBuffer.PositionKind
  27575. * - VertexBuffer.UVKind
  27576. * - VertexBuffer.UV2Kind
  27577. * - VertexBuffer.UV3Kind
  27578. * - VertexBuffer.UV4Kind
  27579. * - VertexBuffer.UV5Kind
  27580. * - VertexBuffer.UV6Kind
  27581. * - VertexBuffer.ColorKind
  27582. * - VertexBuffer.MatricesIndicesKind
  27583. * - VertexBuffer.MatricesIndicesExtraKind
  27584. * - VertexBuffer.MatricesWeightsKind
  27585. * - VertexBuffer.MatricesWeightsExtraKind
  27586. * @param data defines the data source
  27587. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27588. * @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)
  27589. * @returns the current mesh
  27590. */
  27591. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27592. /**
  27593. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  27594. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  27595. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  27596. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  27597. * @returns the current mesh
  27598. */
  27599. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  27600. /**
  27601. * Creates a un-shared specific occurence of the geometry for the mesh.
  27602. * @returns the current mesh
  27603. */
  27604. makeGeometryUnique(): Mesh;
  27605. /**
  27606. * Set the index buffer of this mesh
  27607. * @param indices defines the source data
  27608. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  27609. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  27610. * @returns the current mesh
  27611. */
  27612. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  27613. /**
  27614. * Update the current index buffer
  27615. * @param indices defines the source data
  27616. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27617. * @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)
  27618. * @returns the current mesh
  27619. */
  27620. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27621. /**
  27622. * Invert the geometry to move from a right handed system to a left handed one.
  27623. * @returns the current mesh
  27624. */
  27625. toLeftHanded(): Mesh;
  27626. /** @hidden */
  27627. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  27628. /** @hidden */
  27629. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  27630. /**
  27631. * Registers for this mesh a javascript function called just before the rendering process
  27632. * @param func defines the function to call before rendering this mesh
  27633. * @returns the current mesh
  27634. */
  27635. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27636. /**
  27637. * Disposes a previously registered javascript function called before the rendering
  27638. * @param func defines the function to remove
  27639. * @returns the current mesh
  27640. */
  27641. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27642. /**
  27643. * Registers for this mesh a javascript function called just after the rendering is complete
  27644. * @param func defines the function to call after rendering this mesh
  27645. * @returns the current mesh
  27646. */
  27647. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27648. /**
  27649. * Disposes a previously registered javascript function called after the rendering.
  27650. * @param func defines the function to remove
  27651. * @returns the current mesh
  27652. */
  27653. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27654. /** @hidden */
  27655. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  27656. /** @hidden */
  27657. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  27658. /** @hidden */
  27659. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  27660. /** @hidden */
  27661. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  27662. /** @hidden */
  27663. _rebuild(): void;
  27664. /** @hidden */
  27665. _freeze(): void;
  27666. /** @hidden */
  27667. _unFreeze(): void;
  27668. /**
  27669. * 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
  27670. * @param subMesh defines the subMesh to render
  27671. * @param enableAlphaMode defines if alpha mode can be changed
  27672. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  27673. * @returns the current mesh
  27674. */
  27675. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  27676. private _onBeforeDraw;
  27677. /**
  27678. * Renormalize the mesh and patch it up if there are no weights
  27679. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  27680. * However in the case of zero weights then we set just a single influence to 1.
  27681. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  27682. */
  27683. cleanMatrixWeights(): void;
  27684. private normalizeSkinFourWeights;
  27685. private normalizeSkinWeightsAndExtra;
  27686. /**
  27687. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  27688. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  27689. * the user know there was an issue with importing the mesh
  27690. * @returns a validation object with skinned, valid and report string
  27691. */
  27692. validateSkinning(): {
  27693. skinned: boolean;
  27694. valid: boolean;
  27695. report: string;
  27696. };
  27697. /** @hidden */
  27698. _checkDelayState(): Mesh;
  27699. private _queueLoad;
  27700. /**
  27701. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27702. * A mesh is in the frustum if its bounding box intersects the frustum
  27703. * @param frustumPlanes defines the frustum to test
  27704. * @returns true if the mesh is in the frustum planes
  27705. */
  27706. isInFrustum(frustumPlanes: Plane[]): boolean;
  27707. /**
  27708. * Sets the mesh material by the material or multiMaterial `id` property
  27709. * @param id is a string identifying the material or the multiMaterial
  27710. * @returns the current mesh
  27711. */
  27712. setMaterialByID(id: string): Mesh;
  27713. /**
  27714. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  27715. * @returns an array of IAnimatable
  27716. */
  27717. getAnimatables(): IAnimatable[];
  27718. /**
  27719. * Modifies the mesh geometry according to the passed transformation matrix.
  27720. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  27721. * The mesh normals are modified using the same transformation.
  27722. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27723. * @param transform defines the transform matrix to use
  27724. * @see http://doc.babylonjs.com/resources/baking_transformations
  27725. * @returns the current mesh
  27726. */
  27727. bakeTransformIntoVertices(transform: Matrix): Mesh;
  27728. /**
  27729. * Modifies the mesh geometry according to its own current World Matrix.
  27730. * The mesh World Matrix is then reset.
  27731. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  27732. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27733. * @see http://doc.babylonjs.com/resources/baking_transformations
  27734. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  27735. * @returns the current mesh
  27736. */
  27737. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  27738. /** @hidden */
  27739. get _positions(): Nullable<Vector3[]>;
  27740. /** @hidden */
  27741. _resetPointsArrayCache(): Mesh;
  27742. /** @hidden */
  27743. _generatePointsArray(): boolean;
  27744. /**
  27745. * Returns a new Mesh object generated from the current mesh properties.
  27746. * This method must not get confused with createInstance()
  27747. * @param name is a string, the name given to the new mesh
  27748. * @param newParent can be any Node object (default `null`)
  27749. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  27750. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  27751. * @returns a new mesh
  27752. */
  27753. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  27754. /**
  27755. * Releases resources associated with this mesh.
  27756. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27757. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27758. */
  27759. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27760. /** @hidden */
  27761. _disposeInstanceSpecificData(): void;
  27762. /**
  27763. * Modifies the mesh geometry according to a displacement map.
  27764. * 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.
  27765. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27766. * @param url is a string, the URL from the image file is to be downloaded.
  27767. * @param minHeight is the lower limit of the displacement.
  27768. * @param maxHeight is the upper limit of the displacement.
  27769. * @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.
  27770. * @param uvOffset is an optional vector2 used to offset UV.
  27771. * @param uvScale is an optional vector2 used to scale UV.
  27772. * @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.
  27773. * @returns the Mesh.
  27774. */
  27775. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27776. /**
  27777. * Modifies the mesh geometry according to a displacementMap buffer.
  27778. * 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.
  27779. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27780. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  27781. * @param heightMapWidth is the width of the buffer image.
  27782. * @param heightMapHeight is the height of the buffer image.
  27783. * @param minHeight is the lower limit of the displacement.
  27784. * @param maxHeight is the upper limit of the displacement.
  27785. * @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.
  27786. * @param uvOffset is an optional vector2 used to offset UV.
  27787. * @param uvScale is an optional vector2 used to scale UV.
  27788. * @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.
  27789. * @returns the Mesh.
  27790. */
  27791. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27792. /**
  27793. * Modify the mesh to get a flat shading rendering.
  27794. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  27795. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  27796. * @returns current mesh
  27797. */
  27798. convertToFlatShadedMesh(): Mesh;
  27799. /**
  27800. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  27801. * In other words, more vertices, no more indices and a single bigger VBO.
  27802. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  27803. * @returns current mesh
  27804. */
  27805. convertToUnIndexedMesh(): Mesh;
  27806. /**
  27807. * Inverses facet orientations.
  27808. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27809. * @param flipNormals will also inverts the normals
  27810. * @returns current mesh
  27811. */
  27812. flipFaces(flipNormals?: boolean): Mesh;
  27813. /**
  27814. * Increase the number of facets and hence vertices in a mesh
  27815. * Vertex normals are interpolated from existing vertex normals
  27816. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27817. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  27818. */
  27819. increaseVertices(numberPerEdge: number): void;
  27820. /**
  27821. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  27822. * This will undo any application of covertToFlatShadedMesh
  27823. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27824. */
  27825. forceSharedVertices(): void;
  27826. /** @hidden */
  27827. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  27828. /** @hidden */
  27829. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  27830. /**
  27831. * Creates a new InstancedMesh object from the mesh model.
  27832. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27833. * @param name defines the name of the new instance
  27834. * @returns a new InstancedMesh
  27835. */
  27836. createInstance(name: string): InstancedMesh;
  27837. /**
  27838. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  27839. * After this call, all the mesh instances have the same submeshes than the current mesh.
  27840. * @returns the current mesh
  27841. */
  27842. synchronizeInstances(): Mesh;
  27843. /**
  27844. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  27845. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  27846. * This should be used together with the simplification to avoid disappearing triangles.
  27847. * @param successCallback an optional success callback to be called after the optimization finished.
  27848. * @returns the current mesh
  27849. */
  27850. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  27851. /**
  27852. * Serialize current mesh
  27853. * @param serializationObject defines the object which will receive the serialization data
  27854. */
  27855. serialize(serializationObject: any): void;
  27856. /** @hidden */
  27857. _syncGeometryWithMorphTargetManager(): void;
  27858. /** @hidden */
  27859. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  27860. /**
  27861. * Returns a new Mesh object parsed from the source provided.
  27862. * @param parsedMesh is the source
  27863. * @param scene defines the hosting scene
  27864. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  27865. * @returns a new Mesh
  27866. */
  27867. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  27868. /**
  27869. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  27870. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27871. * @param name defines the name of the mesh to create
  27872. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  27873. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  27874. * @param closePath creates a seam between the first and the last points of each path of the path array
  27875. * @param offset is taken in account only if the `pathArray` is containing a single path
  27876. * @param scene defines the hosting scene
  27877. * @param updatable defines if the mesh must be flagged as updatable
  27878. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27879. * @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)
  27880. * @returns a new Mesh
  27881. */
  27882. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27883. /**
  27884. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  27885. * @param name defines the name of the mesh to create
  27886. * @param radius sets the radius size (float) of the polygon (default 0.5)
  27887. * @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
  27888. * @param scene defines the hosting scene
  27889. * @param updatable defines if the mesh must be flagged as updatable
  27890. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27891. * @returns a new Mesh
  27892. */
  27893. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27894. /**
  27895. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  27896. * @param name defines the name of the mesh to create
  27897. * @param size sets the size (float) of each box side (default 1)
  27898. * @param scene defines the hosting scene
  27899. * @param updatable defines if the mesh must be flagged as updatable
  27900. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27901. * @returns a new Mesh
  27902. */
  27903. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27904. /**
  27905. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  27906. * @param name defines the name of the mesh to create
  27907. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  27908. * @param diameter sets the diameter size (float) of the sphere (default 1)
  27909. * @param scene defines the hosting scene
  27910. * @param updatable defines if the mesh must be flagged as updatable
  27911. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27912. * @returns a new Mesh
  27913. */
  27914. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27915. /**
  27916. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  27917. * @param name defines the name of the mesh to create
  27918. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  27919. * @param diameter sets the diameter size (float) of the sphere (default 1)
  27920. * @param scene defines the hosting scene
  27921. * @returns a new Mesh
  27922. */
  27923. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  27924. /**
  27925. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  27926. * @param name defines the name of the mesh to create
  27927. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  27928. * @param diameterTop set the top cap diameter (floats, default 1)
  27929. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  27930. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  27931. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  27932. * @param scene defines the hosting scene
  27933. * @param updatable defines if the mesh must be flagged as updatable
  27934. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27935. * @returns a new Mesh
  27936. */
  27937. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  27938. /**
  27939. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  27940. * @param name defines the name of the mesh to create
  27941. * @param diameter sets the diameter size (float) of the torus (default 1)
  27942. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  27943. * @param tessellation sets the number of torus sides (postive integer, default 16)
  27944. * @param scene defines the hosting scene
  27945. * @param updatable defines if the mesh must be flagged as updatable
  27946. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27947. * @returns a new Mesh
  27948. */
  27949. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27950. /**
  27951. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  27952. * @param name defines the name of the mesh to create
  27953. * @param radius sets the global radius size (float) of the torus knot (default 2)
  27954. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  27955. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  27956. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  27957. * @param p the number of windings on X axis (positive integers, default 2)
  27958. * @param q the number of windings on Y axis (positive integers, default 3)
  27959. * @param scene defines the hosting scene
  27960. * @param updatable defines if the mesh must be flagged as updatable
  27961. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27962. * @returns a new Mesh
  27963. */
  27964. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27965. /**
  27966. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  27967. * @param name defines the name of the mesh to create
  27968. * @param points is an array successive Vector3
  27969. * @param scene defines the hosting scene
  27970. * @param updatable defines if the mesh must be flagged as updatable
  27971. * @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).
  27972. * @returns a new Mesh
  27973. */
  27974. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  27975. /**
  27976. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  27977. * @param name defines the name of the mesh to create
  27978. * @param points is an array successive Vector3
  27979. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  27980. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  27981. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  27982. * @param scene defines the hosting scene
  27983. * @param updatable defines if the mesh must be flagged as updatable
  27984. * @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)
  27985. * @returns a new Mesh
  27986. */
  27987. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  27988. /**
  27989. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  27990. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  27991. * 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.
  27992. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27993. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27994. * Remember you can only change the shape positions, not their number when updating a polygon.
  27995. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  27996. * @param name defines the name of the mesh to create
  27997. * @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
  27998. * @param scene defines the hosting scene
  27999. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28000. * @param updatable defines if the mesh must be flagged as updatable
  28001. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28002. * @param earcutInjection can be used to inject your own earcut reference
  28003. * @returns a new Mesh
  28004. */
  28005. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28006. /**
  28007. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  28008. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  28009. * @param name defines the name of the mesh to create
  28010. * @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
  28011. * @param depth defines the height of extrusion
  28012. * @param scene defines the hosting scene
  28013. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28014. * @param updatable defines if the mesh must be flagged as updatable
  28015. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28016. * @param earcutInjection can be used to inject your own earcut reference
  28017. * @returns a new Mesh
  28018. */
  28019. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28020. /**
  28021. * Creates an extruded shape mesh.
  28022. * 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
  28023. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28024. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28025. * @param name defines the name of the mesh to create
  28026. * @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
  28027. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28028. * @param scale is the value to scale the shape
  28029. * @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
  28030. * @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
  28031. * @param scene defines the hosting scene
  28032. * @param updatable defines if the mesh must be flagged as updatable
  28033. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28034. * @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)
  28035. * @returns a new Mesh
  28036. */
  28037. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28038. /**
  28039. * Creates an custom extruded shape mesh.
  28040. * The custom extrusion is a parametric shape.
  28041. * It has no predefined shape. Its final shape will depend on the input parameters.
  28042. * Please consider using the same method from the MeshBuilder class instead
  28043. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28044. * @param name defines the name of the mesh to create
  28045. * @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
  28046. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28047. * @param scaleFunction is a custom Javascript function called on each path point
  28048. * @param rotationFunction is a custom Javascript function called on each path point
  28049. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28050. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  28051. * @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
  28052. * @param scene defines the hosting scene
  28053. * @param updatable defines if the mesh must be flagged as updatable
  28054. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28055. * @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)
  28056. * @returns a new Mesh
  28057. */
  28058. 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;
  28059. /**
  28060. * Creates lathe mesh.
  28061. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  28062. * Please consider using the same method from the MeshBuilder class instead
  28063. * @param name defines the name of the mesh to create
  28064. * @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
  28065. * @param radius is the radius value of the lathe
  28066. * @param tessellation is the side number of the lathe.
  28067. * @param scene defines the hosting scene
  28068. * @param updatable defines if the mesh must be flagged as updatable
  28069. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28070. * @returns a new Mesh
  28071. */
  28072. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28073. /**
  28074. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  28075. * @param name defines the name of the mesh to create
  28076. * @param size sets the size (float) of both sides of the plane at once (default 1)
  28077. * @param scene defines the hosting scene
  28078. * @param updatable defines if the mesh must be flagged as updatable
  28079. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28080. * @returns a new Mesh
  28081. */
  28082. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28083. /**
  28084. * Creates a ground mesh.
  28085. * Please consider using the same method from the MeshBuilder class instead
  28086. * @param name defines the name of the mesh to create
  28087. * @param width set the width of the ground
  28088. * @param height set the height of the ground
  28089. * @param subdivisions sets the number of subdivisions per side
  28090. * @param scene defines the hosting scene
  28091. * @param updatable defines if the mesh must be flagged as updatable
  28092. * @returns a new Mesh
  28093. */
  28094. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  28095. /**
  28096. * Creates a tiled ground mesh.
  28097. * Please consider using the same method from the MeshBuilder class instead
  28098. * @param name defines the name of the mesh to create
  28099. * @param xmin set the ground minimum X coordinate
  28100. * @param zmin set the ground minimum Y coordinate
  28101. * @param xmax set the ground maximum X coordinate
  28102. * @param zmax set the ground maximum Z coordinate
  28103. * @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
  28104. * @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
  28105. * @param scene defines the hosting scene
  28106. * @param updatable defines if the mesh must be flagged as updatable
  28107. * @returns a new Mesh
  28108. */
  28109. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  28110. w: number;
  28111. h: number;
  28112. }, precision: {
  28113. w: number;
  28114. h: number;
  28115. }, scene: Scene, updatable?: boolean): Mesh;
  28116. /**
  28117. * Creates a ground mesh from a height map.
  28118. * Please consider using the same method from the MeshBuilder class instead
  28119. * @see http://doc.babylonjs.com/babylon101/height_map
  28120. * @param name defines the name of the mesh to create
  28121. * @param url sets the URL of the height map image resource
  28122. * @param width set the ground width size
  28123. * @param height set the ground height size
  28124. * @param subdivisions sets the number of subdivision per side
  28125. * @param minHeight is the minimum altitude on the ground
  28126. * @param maxHeight is the maximum altitude on the ground
  28127. * @param scene defines the hosting scene
  28128. * @param updatable defines if the mesh must be flagged as updatable
  28129. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  28130. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28131. * @returns a new Mesh
  28132. */
  28133. 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;
  28134. /**
  28135. * Creates a tube mesh.
  28136. * The tube is a parametric shape.
  28137. * It has no predefined shape. Its final shape will depend on the input parameters.
  28138. * Please consider using the same method from the MeshBuilder class instead
  28139. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28140. * @param name defines the name of the mesh to create
  28141. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  28142. * @param radius sets the tube radius size
  28143. * @param tessellation is the number of sides on the tubular surface
  28144. * @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
  28145. * @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
  28146. * @param scene defines the hosting scene
  28147. * @param updatable defines if the mesh must be flagged as updatable
  28148. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28149. * @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)
  28150. * @returns a new Mesh
  28151. */
  28152. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  28153. (i: number, distance: number): number;
  28154. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28155. /**
  28156. * Creates a polyhedron mesh.
  28157. * Please consider using the same method from the MeshBuilder class instead.
  28158. * * 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
  28159. * * The parameter `size` (positive float, default 1) sets the polygon size
  28160. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  28161. * * 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`
  28162. * * 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
  28163. * * 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)`)
  28164. * * 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
  28165. * * 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
  28166. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28167. * * 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
  28168. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28169. * @param name defines the name of the mesh to create
  28170. * @param options defines the options used to create the mesh
  28171. * @param scene defines the hosting scene
  28172. * @returns a new Mesh
  28173. */
  28174. static CreatePolyhedron(name: string, options: {
  28175. type?: number;
  28176. size?: number;
  28177. sizeX?: number;
  28178. sizeY?: number;
  28179. sizeZ?: number;
  28180. custom?: any;
  28181. faceUV?: Vector4[];
  28182. faceColors?: Color4[];
  28183. updatable?: boolean;
  28184. sideOrientation?: number;
  28185. }, scene: Scene): Mesh;
  28186. /**
  28187. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  28188. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  28189. * * 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`)
  28190. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  28191. * * 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
  28192. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28193. * * 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
  28194. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28195. * @param name defines the name of the mesh
  28196. * @param options defines the options used to create the mesh
  28197. * @param scene defines the hosting scene
  28198. * @returns a new Mesh
  28199. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  28200. */
  28201. static CreateIcoSphere(name: string, options: {
  28202. radius?: number;
  28203. flat?: boolean;
  28204. subdivisions?: number;
  28205. sideOrientation?: number;
  28206. updatable?: boolean;
  28207. }, scene: Scene): Mesh;
  28208. /**
  28209. * Creates a decal mesh.
  28210. * Please consider using the same method from the MeshBuilder class instead.
  28211. * A decal is a mesh usually applied as a model onto the surface of another mesh
  28212. * @param name defines the name of the mesh
  28213. * @param sourceMesh defines the mesh receiving the decal
  28214. * @param position sets the position of the decal in world coordinates
  28215. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  28216. * @param size sets the decal scaling
  28217. * @param angle sets the angle to rotate the decal
  28218. * @returns a new Mesh
  28219. */
  28220. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  28221. /**
  28222. * Prepare internal position array for software CPU skinning
  28223. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  28224. */
  28225. setPositionsForCPUSkinning(): Float32Array;
  28226. /**
  28227. * Prepare internal normal array for software CPU skinning
  28228. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  28229. */
  28230. setNormalsForCPUSkinning(): Float32Array;
  28231. /**
  28232. * Updates the vertex buffer by applying transformation from the bones
  28233. * @param skeleton defines the skeleton to apply to current mesh
  28234. * @returns the current mesh
  28235. */
  28236. applySkeleton(skeleton: Skeleton): Mesh;
  28237. /**
  28238. * 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
  28239. * @param meshes defines the list of meshes to scan
  28240. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  28241. */
  28242. static MinMax(meshes: AbstractMesh[]): {
  28243. min: Vector3;
  28244. max: Vector3;
  28245. };
  28246. /**
  28247. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  28248. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  28249. * @returns a vector3
  28250. */
  28251. static Center(meshesOrMinMaxVector: {
  28252. min: Vector3;
  28253. max: Vector3;
  28254. } | AbstractMesh[]): Vector3;
  28255. /**
  28256. * Merge the array of meshes into a single mesh for performance reasons.
  28257. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  28258. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  28259. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  28260. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  28261. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  28262. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  28263. * @returns a new mesh
  28264. */
  28265. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  28266. /** @hidden */
  28267. addInstance(instance: InstancedMesh): void;
  28268. /** @hidden */
  28269. removeInstance(instance: InstancedMesh): void;
  28270. }
  28271. }
  28272. declare module BABYLON {
  28273. /**
  28274. * This is the base class of all the camera used in the application.
  28275. * @see http://doc.babylonjs.com/features/cameras
  28276. */
  28277. export class Camera extends Node {
  28278. /** @hidden */
  28279. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  28280. /**
  28281. * This is the default projection mode used by the cameras.
  28282. * It helps recreating a feeling of perspective and better appreciate depth.
  28283. * This is the best way to simulate real life cameras.
  28284. */
  28285. static readonly PERSPECTIVE_CAMERA: number;
  28286. /**
  28287. * This helps creating camera with an orthographic mode.
  28288. * 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.
  28289. */
  28290. static readonly ORTHOGRAPHIC_CAMERA: number;
  28291. /**
  28292. * This is the default FOV mode for perspective cameras.
  28293. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  28294. */
  28295. static readonly FOVMODE_VERTICAL_FIXED: number;
  28296. /**
  28297. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  28298. */
  28299. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  28300. /**
  28301. * This specifies ther is no need for a camera rig.
  28302. * Basically only one eye is rendered corresponding to the camera.
  28303. */
  28304. static readonly RIG_MODE_NONE: number;
  28305. /**
  28306. * Simulates a camera Rig with one blue eye and one red eye.
  28307. * This can be use with 3d blue and red glasses.
  28308. */
  28309. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  28310. /**
  28311. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  28312. */
  28313. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  28314. /**
  28315. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  28316. */
  28317. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  28318. /**
  28319. * Defines that both eyes of the camera will be rendered over under each other.
  28320. */
  28321. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  28322. /**
  28323. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  28324. */
  28325. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  28326. /**
  28327. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  28328. */
  28329. static readonly RIG_MODE_VR: number;
  28330. /**
  28331. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  28332. */
  28333. static readonly RIG_MODE_WEBVR: number;
  28334. /**
  28335. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  28336. */
  28337. static readonly RIG_MODE_CUSTOM: number;
  28338. /**
  28339. * Defines if by default attaching controls should prevent the default javascript event to continue.
  28340. */
  28341. static ForceAttachControlToAlwaysPreventDefault: boolean;
  28342. /**
  28343. * Define the input manager associated with the camera.
  28344. */
  28345. inputs: CameraInputsManager<Camera>;
  28346. /** @hidden */
  28347. _position: Vector3;
  28348. /**
  28349. * Define the current local position of the camera in the scene
  28350. */
  28351. get position(): Vector3;
  28352. set position(newPosition: Vector3);
  28353. /**
  28354. * The vector the camera should consider as up.
  28355. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  28356. */
  28357. upVector: Vector3;
  28358. /**
  28359. * Define the current limit on the left side for an orthographic camera
  28360. * In scene unit
  28361. */
  28362. orthoLeft: Nullable<number>;
  28363. /**
  28364. * Define the current limit on the right side for an orthographic camera
  28365. * In scene unit
  28366. */
  28367. orthoRight: Nullable<number>;
  28368. /**
  28369. * Define the current limit on the bottom side for an orthographic camera
  28370. * In scene unit
  28371. */
  28372. orthoBottom: Nullable<number>;
  28373. /**
  28374. * Define the current limit on the top side for an orthographic camera
  28375. * In scene unit
  28376. */
  28377. orthoTop: Nullable<number>;
  28378. /**
  28379. * Field Of View is set in Radians. (default is 0.8)
  28380. */
  28381. fov: number;
  28382. /**
  28383. * Define the minimum distance the camera can see from.
  28384. * This is important to note that the depth buffer are not infinite and the closer it starts
  28385. * the more your scene might encounter depth fighting issue.
  28386. */
  28387. minZ: number;
  28388. /**
  28389. * Define the maximum distance the camera can see to.
  28390. * This is important to note that the depth buffer are not infinite and the further it end
  28391. * the more your scene might encounter depth fighting issue.
  28392. */
  28393. maxZ: number;
  28394. /**
  28395. * Define the default inertia of the camera.
  28396. * This helps giving a smooth feeling to the camera movement.
  28397. */
  28398. inertia: number;
  28399. /**
  28400. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  28401. */
  28402. mode: number;
  28403. /**
  28404. * Define whether the camera is intermediate.
  28405. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  28406. */
  28407. isIntermediate: boolean;
  28408. /**
  28409. * Define the viewport of the camera.
  28410. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  28411. */
  28412. viewport: Viewport;
  28413. /**
  28414. * Restricts the camera to viewing objects with the same layerMask.
  28415. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  28416. */
  28417. layerMask: number;
  28418. /**
  28419. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  28420. */
  28421. fovMode: number;
  28422. /**
  28423. * Rig mode of the camera.
  28424. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  28425. * This is normally controlled byt the camera themselves as internal use.
  28426. */
  28427. cameraRigMode: number;
  28428. /**
  28429. * Defines the distance between both "eyes" in case of a RIG
  28430. */
  28431. interaxialDistance: number;
  28432. /**
  28433. * Defines if stereoscopic rendering is done side by side or over under.
  28434. */
  28435. isStereoscopicSideBySide: boolean;
  28436. /**
  28437. * 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
  28438. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  28439. * else in the scene. (Eg. security camera)
  28440. *
  28441. * 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)
  28442. */
  28443. customRenderTargets: RenderTargetTexture[];
  28444. /**
  28445. * When set, the camera will render to this render target instead of the default canvas
  28446. *
  28447. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  28448. */
  28449. outputRenderTarget: Nullable<RenderTargetTexture>;
  28450. /**
  28451. * Observable triggered when the camera view matrix has changed.
  28452. */
  28453. onViewMatrixChangedObservable: Observable<Camera>;
  28454. /**
  28455. * Observable triggered when the camera Projection matrix has changed.
  28456. */
  28457. onProjectionMatrixChangedObservable: Observable<Camera>;
  28458. /**
  28459. * Observable triggered when the inputs have been processed.
  28460. */
  28461. onAfterCheckInputsObservable: Observable<Camera>;
  28462. /**
  28463. * Observable triggered when reset has been called and applied to the camera.
  28464. */
  28465. onRestoreStateObservable: Observable<Camera>;
  28466. /**
  28467. * Is this camera a part of a rig system?
  28468. */
  28469. isRigCamera: boolean;
  28470. /**
  28471. * If isRigCamera set to true this will be set with the parent camera.
  28472. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  28473. */
  28474. rigParent?: Camera;
  28475. /** @hidden */
  28476. _cameraRigParams: any;
  28477. /** @hidden */
  28478. _rigCameras: Camera[];
  28479. /** @hidden */
  28480. _rigPostProcess: Nullable<PostProcess>;
  28481. protected _webvrViewMatrix: Matrix;
  28482. /** @hidden */
  28483. _skipRendering: boolean;
  28484. /** @hidden */
  28485. _projectionMatrix: Matrix;
  28486. /** @hidden */
  28487. _postProcesses: Nullable<PostProcess>[];
  28488. /** @hidden */
  28489. _activeMeshes: SmartArray<AbstractMesh>;
  28490. protected _globalPosition: Vector3;
  28491. /** @hidden */
  28492. _computedViewMatrix: Matrix;
  28493. private _doNotComputeProjectionMatrix;
  28494. private _transformMatrix;
  28495. private _frustumPlanes;
  28496. private _refreshFrustumPlanes;
  28497. private _storedFov;
  28498. private _stateStored;
  28499. /**
  28500. * Instantiates a new camera object.
  28501. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  28502. * @see http://doc.babylonjs.com/features/cameras
  28503. * @param name Defines the name of the camera in the scene
  28504. * @param position Defines the position of the camera
  28505. * @param scene Defines the scene the camera belongs too
  28506. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  28507. */
  28508. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  28509. /**
  28510. * Store current camera state (fov, position, etc..)
  28511. * @returns the camera
  28512. */
  28513. storeState(): Camera;
  28514. /**
  28515. * Restores the camera state values if it has been stored. You must call storeState() first
  28516. */
  28517. protected _restoreStateValues(): boolean;
  28518. /**
  28519. * Restored camera state. You must call storeState() first.
  28520. * @returns true if restored and false otherwise
  28521. */
  28522. restoreState(): boolean;
  28523. /**
  28524. * Gets the class name of the camera.
  28525. * @returns the class name
  28526. */
  28527. getClassName(): string;
  28528. /** @hidden */
  28529. readonly _isCamera: boolean;
  28530. /**
  28531. * Gets a string representation of the camera useful for debug purpose.
  28532. * @param fullDetails Defines that a more verboe level of logging is required
  28533. * @returns the string representation
  28534. */
  28535. toString(fullDetails?: boolean): string;
  28536. /**
  28537. * Gets the current world space position of the camera.
  28538. */
  28539. get globalPosition(): Vector3;
  28540. /**
  28541. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  28542. * @returns the active meshe list
  28543. */
  28544. getActiveMeshes(): SmartArray<AbstractMesh>;
  28545. /**
  28546. * Check whether a mesh is part of the current active mesh list of the camera
  28547. * @param mesh Defines the mesh to check
  28548. * @returns true if active, false otherwise
  28549. */
  28550. isActiveMesh(mesh: Mesh): boolean;
  28551. /**
  28552. * Is this camera ready to be used/rendered
  28553. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  28554. * @return true if the camera is ready
  28555. */
  28556. isReady(completeCheck?: boolean): boolean;
  28557. /** @hidden */
  28558. _initCache(): void;
  28559. /** @hidden */
  28560. _updateCache(ignoreParentClass?: boolean): void;
  28561. /** @hidden */
  28562. _isSynchronized(): boolean;
  28563. /** @hidden */
  28564. _isSynchronizedViewMatrix(): boolean;
  28565. /** @hidden */
  28566. _isSynchronizedProjectionMatrix(): boolean;
  28567. /**
  28568. * Attach the input controls to a specific dom element to get the input from.
  28569. * @param element Defines the element the controls should be listened from
  28570. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  28571. */
  28572. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  28573. /**
  28574. * Detach the current controls from the specified dom element.
  28575. * @param element Defines the element to stop listening the inputs from
  28576. */
  28577. detachControl(element: HTMLElement): void;
  28578. /**
  28579. * Update the camera state according to the different inputs gathered during the frame.
  28580. */
  28581. update(): void;
  28582. /** @hidden */
  28583. _checkInputs(): void;
  28584. /** @hidden */
  28585. get rigCameras(): Camera[];
  28586. /**
  28587. * Gets the post process used by the rig cameras
  28588. */
  28589. get rigPostProcess(): Nullable<PostProcess>;
  28590. /**
  28591. * Internal, gets the first post proces.
  28592. * @returns the first post process to be run on this camera.
  28593. */
  28594. _getFirstPostProcess(): Nullable<PostProcess>;
  28595. private _cascadePostProcessesToRigCams;
  28596. /**
  28597. * Attach a post process to the camera.
  28598. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  28599. * @param postProcess The post process to attach to the camera
  28600. * @param insertAt The position of the post process in case several of them are in use in the scene
  28601. * @returns the position the post process has been inserted at
  28602. */
  28603. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  28604. /**
  28605. * Detach a post process to the camera.
  28606. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  28607. * @param postProcess The post process to detach from the camera
  28608. */
  28609. detachPostProcess(postProcess: PostProcess): void;
  28610. /**
  28611. * Gets the current world matrix of the camera
  28612. */
  28613. getWorldMatrix(): Matrix;
  28614. /** @hidden */
  28615. _getViewMatrix(): Matrix;
  28616. /**
  28617. * Gets the current view matrix of the camera.
  28618. * @param force forces the camera to recompute the matrix without looking at the cached state
  28619. * @returns the view matrix
  28620. */
  28621. getViewMatrix(force?: boolean): Matrix;
  28622. /**
  28623. * Freeze the projection matrix.
  28624. * It will prevent the cache check of the camera projection compute and can speed up perf
  28625. * if no parameter of the camera are meant to change
  28626. * @param projection Defines manually a projection if necessary
  28627. */
  28628. freezeProjectionMatrix(projection?: Matrix): void;
  28629. /**
  28630. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  28631. */
  28632. unfreezeProjectionMatrix(): void;
  28633. /**
  28634. * Gets the current projection matrix of the camera.
  28635. * @param force forces the camera to recompute the matrix without looking at the cached state
  28636. * @returns the projection matrix
  28637. */
  28638. getProjectionMatrix(force?: boolean): Matrix;
  28639. /**
  28640. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  28641. * @returns a Matrix
  28642. */
  28643. getTransformationMatrix(): Matrix;
  28644. private _updateFrustumPlanes;
  28645. /**
  28646. * Checks if a cullable object (mesh...) is in the camera frustum
  28647. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  28648. * @param target The object to check
  28649. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  28650. * @returns true if the object is in frustum otherwise false
  28651. */
  28652. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  28653. /**
  28654. * Checks if a cullable object (mesh...) is in the camera frustum
  28655. * Unlike isInFrustum this cheks the full bounding box
  28656. * @param target The object to check
  28657. * @returns true if the object is in frustum otherwise false
  28658. */
  28659. isCompletelyInFrustum(target: ICullable): boolean;
  28660. /**
  28661. * Gets a ray in the forward direction from the camera.
  28662. * @param length Defines the length of the ray to create
  28663. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  28664. * @param origin Defines the start point of the ray which defaults to the camera position
  28665. * @returns the forward ray
  28666. */
  28667. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  28668. /**
  28669. * Releases resources associated with this node.
  28670. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28671. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28672. */
  28673. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28674. /** @hidden */
  28675. _isLeftCamera: boolean;
  28676. /**
  28677. * Gets the left camera of a rig setup in case of Rigged Camera
  28678. */
  28679. get isLeftCamera(): boolean;
  28680. /** @hidden */
  28681. _isRightCamera: boolean;
  28682. /**
  28683. * Gets the right camera of a rig setup in case of Rigged Camera
  28684. */
  28685. get isRightCamera(): boolean;
  28686. /**
  28687. * Gets the left camera of a rig setup in case of Rigged Camera
  28688. */
  28689. get leftCamera(): Nullable<FreeCamera>;
  28690. /**
  28691. * Gets the right camera of a rig setup in case of Rigged Camera
  28692. */
  28693. get rightCamera(): Nullable<FreeCamera>;
  28694. /**
  28695. * Gets the left camera target of a rig setup in case of Rigged Camera
  28696. * @returns the target position
  28697. */
  28698. getLeftTarget(): Nullable<Vector3>;
  28699. /**
  28700. * Gets the right camera target of a rig setup in case of Rigged Camera
  28701. * @returns the target position
  28702. */
  28703. getRightTarget(): Nullable<Vector3>;
  28704. /**
  28705. * @hidden
  28706. */
  28707. setCameraRigMode(mode: number, rigParams: any): void;
  28708. /** @hidden */
  28709. static _setStereoscopicRigMode(camera: Camera): void;
  28710. /** @hidden */
  28711. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  28712. /** @hidden */
  28713. static _setVRRigMode(camera: Camera, rigParams: any): void;
  28714. /** @hidden */
  28715. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  28716. /** @hidden */
  28717. _getVRProjectionMatrix(): Matrix;
  28718. protected _updateCameraRotationMatrix(): void;
  28719. protected _updateWebVRCameraRotationMatrix(): void;
  28720. /**
  28721. * This function MUST be overwritten by the different WebVR cameras available.
  28722. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  28723. * @hidden
  28724. */
  28725. _getWebVRProjectionMatrix(): Matrix;
  28726. /**
  28727. * This function MUST be overwritten by the different WebVR cameras available.
  28728. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  28729. * @hidden
  28730. */
  28731. _getWebVRViewMatrix(): Matrix;
  28732. /** @hidden */
  28733. setCameraRigParameter(name: string, value: any): void;
  28734. /**
  28735. * needs to be overridden by children so sub has required properties to be copied
  28736. * @hidden
  28737. */
  28738. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  28739. /**
  28740. * May need to be overridden by children
  28741. * @hidden
  28742. */
  28743. _updateRigCameras(): void;
  28744. /** @hidden */
  28745. _setupInputs(): void;
  28746. /**
  28747. * Serialiaze the camera setup to a json represention
  28748. * @returns the JSON representation
  28749. */
  28750. serialize(): any;
  28751. /**
  28752. * Clones the current camera.
  28753. * @param name The cloned camera name
  28754. * @returns the cloned camera
  28755. */
  28756. clone(name: string): Camera;
  28757. /**
  28758. * Gets the direction of the camera relative to a given local axis.
  28759. * @param localAxis Defines the reference axis to provide a relative direction.
  28760. * @return the direction
  28761. */
  28762. getDirection(localAxis: Vector3): Vector3;
  28763. /**
  28764. * Returns the current camera absolute rotation
  28765. */
  28766. get absoluteRotation(): Quaternion;
  28767. /**
  28768. * Gets the direction of the camera relative to a given local axis into a passed vector.
  28769. * @param localAxis Defines the reference axis to provide a relative direction.
  28770. * @param result Defines the vector to store the result in
  28771. */
  28772. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  28773. /**
  28774. * Gets a camera constructor for a given camera type
  28775. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  28776. * @param name The name of the camera the result will be able to instantiate
  28777. * @param scene The scene the result will construct the camera in
  28778. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  28779. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  28780. * @returns a factory method to construc the camera
  28781. */
  28782. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  28783. /**
  28784. * Compute the world matrix of the camera.
  28785. * @returns the camera world matrix
  28786. */
  28787. computeWorldMatrix(): Matrix;
  28788. /**
  28789. * Parse a JSON and creates the camera from the parsed information
  28790. * @param parsedCamera The JSON to parse
  28791. * @param scene The scene to instantiate the camera in
  28792. * @returns the newly constructed camera
  28793. */
  28794. static Parse(parsedCamera: any, scene: Scene): Camera;
  28795. }
  28796. }
  28797. declare module BABYLON {
  28798. /**
  28799. * Class containing static functions to help procedurally build meshes
  28800. */
  28801. export class DiscBuilder {
  28802. /**
  28803. * Creates a plane polygonal mesh. By default, this is a disc
  28804. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  28805. * * 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
  28806. * * 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
  28807. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28808. * * 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
  28809. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28810. * @param name defines the name of the mesh
  28811. * @param options defines the options used to create the mesh
  28812. * @param scene defines the hosting scene
  28813. * @returns the plane polygonal mesh
  28814. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  28815. */
  28816. static CreateDisc(name: string, options: {
  28817. radius?: number;
  28818. tessellation?: number;
  28819. arc?: number;
  28820. updatable?: boolean;
  28821. sideOrientation?: number;
  28822. frontUVs?: Vector4;
  28823. backUVs?: Vector4;
  28824. }, scene?: Nullable<Scene>): Mesh;
  28825. }
  28826. }
  28827. declare module BABYLON {
  28828. /**
  28829. * Options to be used when creating a FresnelParameters.
  28830. */
  28831. export type IFresnelParametersCreationOptions = {
  28832. /**
  28833. * Define the color used on edges (grazing angle)
  28834. */
  28835. leftColor?: Color3;
  28836. /**
  28837. * Define the color used on center
  28838. */
  28839. rightColor?: Color3;
  28840. /**
  28841. * Define bias applied to computed fresnel term
  28842. */
  28843. bias?: number;
  28844. /**
  28845. * Defined the power exponent applied to fresnel term
  28846. */
  28847. power?: number;
  28848. /**
  28849. * Define if the fresnel effect is enable or not.
  28850. */
  28851. isEnabled?: boolean;
  28852. };
  28853. /**
  28854. * Serialized format for FresnelParameters.
  28855. */
  28856. export type IFresnelParametersSerialized = {
  28857. /**
  28858. * Define the color used on edges (grazing angle) [as an array]
  28859. */
  28860. leftColor: number[];
  28861. /**
  28862. * Define the color used on center [as an array]
  28863. */
  28864. rightColor: number[];
  28865. /**
  28866. * Define bias applied to computed fresnel term
  28867. */
  28868. bias: number;
  28869. /**
  28870. * Defined the power exponent applied to fresnel term
  28871. */
  28872. power?: number;
  28873. /**
  28874. * Define if the fresnel effect is enable or not.
  28875. */
  28876. isEnabled: boolean;
  28877. };
  28878. /**
  28879. * This represents all the required information to add a fresnel effect on a material:
  28880. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28881. */
  28882. export class FresnelParameters {
  28883. private _isEnabled;
  28884. /**
  28885. * Define if the fresnel effect is enable or not.
  28886. */
  28887. get isEnabled(): boolean;
  28888. set isEnabled(value: boolean);
  28889. /**
  28890. * Define the color used on edges (grazing angle)
  28891. */
  28892. leftColor: Color3;
  28893. /**
  28894. * Define the color used on center
  28895. */
  28896. rightColor: Color3;
  28897. /**
  28898. * Define bias applied to computed fresnel term
  28899. */
  28900. bias: number;
  28901. /**
  28902. * Defined the power exponent applied to fresnel term
  28903. */
  28904. power: number;
  28905. /**
  28906. * Creates a new FresnelParameters object.
  28907. *
  28908. * @param options provide your own settings to optionally to override defaults
  28909. */
  28910. constructor(options?: IFresnelParametersCreationOptions);
  28911. /**
  28912. * Clones the current fresnel and its valuues
  28913. * @returns a clone fresnel configuration
  28914. */
  28915. clone(): FresnelParameters;
  28916. /**
  28917. * Determines equality between FresnelParameters objects
  28918. * @param otherFresnelParameters defines the second operand
  28919. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  28920. */
  28921. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  28922. /**
  28923. * Serializes the current fresnel parameters to a JSON representation.
  28924. * @return the JSON serialization
  28925. */
  28926. serialize(): IFresnelParametersSerialized;
  28927. /**
  28928. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28929. * @param parsedFresnelParameters Define the JSON representation
  28930. * @returns the parsed parameters
  28931. */
  28932. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  28933. }
  28934. }
  28935. declare module BABYLON {
  28936. /**
  28937. * This groups all the flags used to control the materials channel.
  28938. */
  28939. export class MaterialFlags {
  28940. private static _DiffuseTextureEnabled;
  28941. /**
  28942. * Are diffuse textures enabled in the application.
  28943. */
  28944. static get DiffuseTextureEnabled(): boolean;
  28945. static set DiffuseTextureEnabled(value: boolean);
  28946. private static _AmbientTextureEnabled;
  28947. /**
  28948. * Are ambient textures enabled in the application.
  28949. */
  28950. static get AmbientTextureEnabled(): boolean;
  28951. static set AmbientTextureEnabled(value: boolean);
  28952. private static _OpacityTextureEnabled;
  28953. /**
  28954. * Are opacity textures enabled in the application.
  28955. */
  28956. static get OpacityTextureEnabled(): boolean;
  28957. static set OpacityTextureEnabled(value: boolean);
  28958. private static _ReflectionTextureEnabled;
  28959. /**
  28960. * Are reflection textures enabled in the application.
  28961. */
  28962. static get ReflectionTextureEnabled(): boolean;
  28963. static set ReflectionTextureEnabled(value: boolean);
  28964. private static _EmissiveTextureEnabled;
  28965. /**
  28966. * Are emissive textures enabled in the application.
  28967. */
  28968. static get EmissiveTextureEnabled(): boolean;
  28969. static set EmissiveTextureEnabled(value: boolean);
  28970. private static _SpecularTextureEnabled;
  28971. /**
  28972. * Are specular textures enabled in the application.
  28973. */
  28974. static get SpecularTextureEnabled(): boolean;
  28975. static set SpecularTextureEnabled(value: boolean);
  28976. private static _BumpTextureEnabled;
  28977. /**
  28978. * Are bump textures enabled in the application.
  28979. */
  28980. static get BumpTextureEnabled(): boolean;
  28981. static set BumpTextureEnabled(value: boolean);
  28982. private static _LightmapTextureEnabled;
  28983. /**
  28984. * Are lightmap textures enabled in the application.
  28985. */
  28986. static get LightmapTextureEnabled(): boolean;
  28987. static set LightmapTextureEnabled(value: boolean);
  28988. private static _RefractionTextureEnabled;
  28989. /**
  28990. * Are refraction textures enabled in the application.
  28991. */
  28992. static get RefractionTextureEnabled(): boolean;
  28993. static set RefractionTextureEnabled(value: boolean);
  28994. private static _ColorGradingTextureEnabled;
  28995. /**
  28996. * Are color grading textures enabled in the application.
  28997. */
  28998. static get ColorGradingTextureEnabled(): boolean;
  28999. static set ColorGradingTextureEnabled(value: boolean);
  29000. private static _FresnelEnabled;
  29001. /**
  29002. * Are fresnels enabled in the application.
  29003. */
  29004. static get FresnelEnabled(): boolean;
  29005. static set FresnelEnabled(value: boolean);
  29006. private static _ClearCoatTextureEnabled;
  29007. /**
  29008. * Are clear coat textures enabled in the application.
  29009. */
  29010. static get ClearCoatTextureEnabled(): boolean;
  29011. static set ClearCoatTextureEnabled(value: boolean);
  29012. private static _ClearCoatBumpTextureEnabled;
  29013. /**
  29014. * Are clear coat bump textures enabled in the application.
  29015. */
  29016. static get ClearCoatBumpTextureEnabled(): boolean;
  29017. static set ClearCoatBumpTextureEnabled(value: boolean);
  29018. private static _ClearCoatTintTextureEnabled;
  29019. /**
  29020. * Are clear coat tint textures enabled in the application.
  29021. */
  29022. static get ClearCoatTintTextureEnabled(): boolean;
  29023. static set ClearCoatTintTextureEnabled(value: boolean);
  29024. private static _SheenTextureEnabled;
  29025. /**
  29026. * Are sheen textures enabled in the application.
  29027. */
  29028. static get SheenTextureEnabled(): boolean;
  29029. static set SheenTextureEnabled(value: boolean);
  29030. private static _AnisotropicTextureEnabled;
  29031. /**
  29032. * Are anisotropic textures enabled in the application.
  29033. */
  29034. static get AnisotropicTextureEnabled(): boolean;
  29035. static set AnisotropicTextureEnabled(value: boolean);
  29036. private static _ThicknessTextureEnabled;
  29037. /**
  29038. * Are thickness textures enabled in the application.
  29039. */
  29040. static get ThicknessTextureEnabled(): boolean;
  29041. static set ThicknessTextureEnabled(value: boolean);
  29042. }
  29043. }
  29044. declare module BABYLON {
  29045. /** @hidden */
  29046. export var defaultFragmentDeclaration: {
  29047. name: string;
  29048. shader: string;
  29049. };
  29050. }
  29051. declare module BABYLON {
  29052. /** @hidden */
  29053. export var defaultUboDeclaration: {
  29054. name: string;
  29055. shader: string;
  29056. };
  29057. }
  29058. declare module BABYLON {
  29059. /** @hidden */
  29060. export var lightFragmentDeclaration: {
  29061. name: string;
  29062. shader: string;
  29063. };
  29064. }
  29065. declare module BABYLON {
  29066. /** @hidden */
  29067. export var lightUboDeclaration: {
  29068. name: string;
  29069. shader: string;
  29070. };
  29071. }
  29072. declare module BABYLON {
  29073. /** @hidden */
  29074. export var lightsFragmentFunctions: {
  29075. name: string;
  29076. shader: string;
  29077. };
  29078. }
  29079. declare module BABYLON {
  29080. /** @hidden */
  29081. export var shadowsFragmentFunctions: {
  29082. name: string;
  29083. shader: string;
  29084. };
  29085. }
  29086. declare module BABYLON {
  29087. /** @hidden */
  29088. export var fresnelFunction: {
  29089. name: string;
  29090. shader: string;
  29091. };
  29092. }
  29093. declare module BABYLON {
  29094. /** @hidden */
  29095. export var bumpFragmentMainFunctions: {
  29096. name: string;
  29097. shader: string;
  29098. };
  29099. }
  29100. declare module BABYLON {
  29101. /** @hidden */
  29102. export var bumpFragmentFunctions: {
  29103. name: string;
  29104. shader: string;
  29105. };
  29106. }
  29107. declare module BABYLON {
  29108. /** @hidden */
  29109. export var logDepthDeclaration: {
  29110. name: string;
  29111. shader: string;
  29112. };
  29113. }
  29114. declare module BABYLON {
  29115. /** @hidden */
  29116. export var bumpFragment: {
  29117. name: string;
  29118. shader: string;
  29119. };
  29120. }
  29121. declare module BABYLON {
  29122. /** @hidden */
  29123. export var depthPrePass: {
  29124. name: string;
  29125. shader: string;
  29126. };
  29127. }
  29128. declare module BABYLON {
  29129. /** @hidden */
  29130. export var lightFragment: {
  29131. name: string;
  29132. shader: string;
  29133. };
  29134. }
  29135. declare module BABYLON {
  29136. /** @hidden */
  29137. export var logDepthFragment: {
  29138. name: string;
  29139. shader: string;
  29140. };
  29141. }
  29142. declare module BABYLON {
  29143. /** @hidden */
  29144. export var defaultPixelShader: {
  29145. name: string;
  29146. shader: string;
  29147. };
  29148. }
  29149. declare module BABYLON {
  29150. /** @hidden */
  29151. export var defaultVertexDeclaration: {
  29152. name: string;
  29153. shader: string;
  29154. };
  29155. }
  29156. declare module BABYLON {
  29157. /** @hidden */
  29158. export var bumpVertexDeclaration: {
  29159. name: string;
  29160. shader: string;
  29161. };
  29162. }
  29163. declare module BABYLON {
  29164. /** @hidden */
  29165. export var bumpVertex: {
  29166. name: string;
  29167. shader: string;
  29168. };
  29169. }
  29170. declare module BABYLON {
  29171. /** @hidden */
  29172. export var fogVertex: {
  29173. name: string;
  29174. shader: string;
  29175. };
  29176. }
  29177. declare module BABYLON {
  29178. /** @hidden */
  29179. export var shadowsVertex: {
  29180. name: string;
  29181. shader: string;
  29182. };
  29183. }
  29184. declare module BABYLON {
  29185. /** @hidden */
  29186. export var pointCloudVertex: {
  29187. name: string;
  29188. shader: string;
  29189. };
  29190. }
  29191. declare module BABYLON {
  29192. /** @hidden */
  29193. export var logDepthVertex: {
  29194. name: string;
  29195. shader: string;
  29196. };
  29197. }
  29198. declare module BABYLON {
  29199. /** @hidden */
  29200. export var defaultVertexShader: {
  29201. name: string;
  29202. shader: string;
  29203. };
  29204. }
  29205. declare module BABYLON {
  29206. /** @hidden */
  29207. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29208. MAINUV1: boolean;
  29209. MAINUV2: boolean;
  29210. DIFFUSE: boolean;
  29211. DIFFUSEDIRECTUV: number;
  29212. AMBIENT: boolean;
  29213. AMBIENTDIRECTUV: number;
  29214. OPACITY: boolean;
  29215. OPACITYDIRECTUV: number;
  29216. OPACITYRGB: boolean;
  29217. REFLECTION: boolean;
  29218. EMISSIVE: boolean;
  29219. EMISSIVEDIRECTUV: number;
  29220. SPECULAR: boolean;
  29221. SPECULARDIRECTUV: number;
  29222. BUMP: boolean;
  29223. BUMPDIRECTUV: number;
  29224. PARALLAX: boolean;
  29225. PARALLAXOCCLUSION: boolean;
  29226. SPECULAROVERALPHA: boolean;
  29227. CLIPPLANE: boolean;
  29228. CLIPPLANE2: boolean;
  29229. CLIPPLANE3: boolean;
  29230. CLIPPLANE4: boolean;
  29231. CLIPPLANE5: boolean;
  29232. CLIPPLANE6: boolean;
  29233. ALPHATEST: boolean;
  29234. DEPTHPREPASS: boolean;
  29235. ALPHAFROMDIFFUSE: boolean;
  29236. POINTSIZE: boolean;
  29237. FOG: boolean;
  29238. SPECULARTERM: boolean;
  29239. DIFFUSEFRESNEL: boolean;
  29240. OPACITYFRESNEL: boolean;
  29241. REFLECTIONFRESNEL: boolean;
  29242. REFRACTIONFRESNEL: boolean;
  29243. EMISSIVEFRESNEL: boolean;
  29244. FRESNEL: boolean;
  29245. NORMAL: boolean;
  29246. UV1: boolean;
  29247. UV2: boolean;
  29248. VERTEXCOLOR: boolean;
  29249. VERTEXALPHA: boolean;
  29250. NUM_BONE_INFLUENCERS: number;
  29251. BonesPerMesh: number;
  29252. BONETEXTURE: boolean;
  29253. INSTANCES: boolean;
  29254. GLOSSINESS: boolean;
  29255. ROUGHNESS: boolean;
  29256. EMISSIVEASILLUMINATION: boolean;
  29257. LINKEMISSIVEWITHDIFFUSE: boolean;
  29258. REFLECTIONFRESNELFROMSPECULAR: boolean;
  29259. LIGHTMAP: boolean;
  29260. LIGHTMAPDIRECTUV: number;
  29261. OBJECTSPACE_NORMALMAP: boolean;
  29262. USELIGHTMAPASSHADOWMAP: boolean;
  29263. REFLECTIONMAP_3D: boolean;
  29264. REFLECTIONMAP_SPHERICAL: boolean;
  29265. REFLECTIONMAP_PLANAR: boolean;
  29266. REFLECTIONMAP_CUBIC: boolean;
  29267. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  29268. REFLECTIONMAP_PROJECTION: boolean;
  29269. REFLECTIONMAP_SKYBOX: boolean;
  29270. REFLECTIONMAP_EXPLICIT: boolean;
  29271. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  29272. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  29273. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  29274. INVERTCUBICMAP: boolean;
  29275. LOGARITHMICDEPTH: boolean;
  29276. REFRACTION: boolean;
  29277. REFRACTIONMAP_3D: boolean;
  29278. REFLECTIONOVERALPHA: boolean;
  29279. TWOSIDEDLIGHTING: boolean;
  29280. SHADOWFLOAT: boolean;
  29281. MORPHTARGETS: boolean;
  29282. MORPHTARGETS_NORMAL: boolean;
  29283. MORPHTARGETS_TANGENT: boolean;
  29284. MORPHTARGETS_UV: boolean;
  29285. NUM_MORPH_INFLUENCERS: number;
  29286. NONUNIFORMSCALING: boolean;
  29287. PREMULTIPLYALPHA: boolean;
  29288. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  29289. ALPHABLEND: boolean;
  29290. RGBDLIGHTMAP: boolean;
  29291. RGBDREFLECTION: boolean;
  29292. RGBDREFRACTION: boolean;
  29293. IMAGEPROCESSING: boolean;
  29294. VIGNETTE: boolean;
  29295. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29296. VIGNETTEBLENDMODEOPAQUE: boolean;
  29297. TONEMAPPING: boolean;
  29298. TONEMAPPING_ACES: boolean;
  29299. CONTRAST: boolean;
  29300. COLORCURVES: boolean;
  29301. COLORGRADING: boolean;
  29302. COLORGRADING3D: boolean;
  29303. SAMPLER3DGREENDEPTH: boolean;
  29304. SAMPLER3DBGRMAP: boolean;
  29305. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29306. MULTIVIEW: boolean;
  29307. /**
  29308. * If the reflection texture on this material is in linear color space
  29309. * @hidden
  29310. */
  29311. IS_REFLECTION_LINEAR: boolean;
  29312. /**
  29313. * If the refraction texture on this material is in linear color space
  29314. * @hidden
  29315. */
  29316. IS_REFRACTION_LINEAR: boolean;
  29317. EXPOSURE: boolean;
  29318. constructor();
  29319. setReflectionMode(modeToEnable: string): void;
  29320. }
  29321. /**
  29322. * This is the default material used in Babylon. It is the best trade off between quality
  29323. * and performances.
  29324. * @see http://doc.babylonjs.com/babylon101/materials
  29325. */
  29326. export class StandardMaterial extends PushMaterial {
  29327. private _diffuseTexture;
  29328. /**
  29329. * The basic texture of the material as viewed under a light.
  29330. */
  29331. diffuseTexture: Nullable<BaseTexture>;
  29332. private _ambientTexture;
  29333. /**
  29334. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  29335. */
  29336. ambientTexture: Nullable<BaseTexture>;
  29337. private _opacityTexture;
  29338. /**
  29339. * Define the transparency of the material from a texture.
  29340. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  29341. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  29342. */
  29343. opacityTexture: Nullable<BaseTexture>;
  29344. private _reflectionTexture;
  29345. /**
  29346. * Define the texture used to display the reflection.
  29347. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29348. */
  29349. reflectionTexture: Nullable<BaseTexture>;
  29350. private _emissiveTexture;
  29351. /**
  29352. * Define texture of the material as if self lit.
  29353. * This will be mixed in the final result even in the absence of light.
  29354. */
  29355. emissiveTexture: Nullable<BaseTexture>;
  29356. private _specularTexture;
  29357. /**
  29358. * Define how the color and intensity of the highlight given by the light in the material.
  29359. */
  29360. specularTexture: Nullable<BaseTexture>;
  29361. private _bumpTexture;
  29362. /**
  29363. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  29364. * 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.
  29365. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  29366. */
  29367. bumpTexture: Nullable<BaseTexture>;
  29368. private _lightmapTexture;
  29369. /**
  29370. * Complex lighting can be computationally expensive to compute at runtime.
  29371. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  29372. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  29373. */
  29374. lightmapTexture: Nullable<BaseTexture>;
  29375. private _refractionTexture;
  29376. /**
  29377. * Define the texture used to display the refraction.
  29378. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29379. */
  29380. refractionTexture: Nullable<BaseTexture>;
  29381. /**
  29382. * The color of the material lit by the environmental background lighting.
  29383. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  29384. */
  29385. ambientColor: Color3;
  29386. /**
  29387. * The basic color of the material as viewed under a light.
  29388. */
  29389. diffuseColor: Color3;
  29390. /**
  29391. * Define how the color and intensity of the highlight given by the light in the material.
  29392. */
  29393. specularColor: Color3;
  29394. /**
  29395. * Define the color of the material as if self lit.
  29396. * This will be mixed in the final result even in the absence of light.
  29397. */
  29398. emissiveColor: Color3;
  29399. /**
  29400. * Defines how sharp are the highlights in the material.
  29401. * The bigger the value the sharper giving a more glossy feeling to the result.
  29402. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  29403. */
  29404. specularPower: number;
  29405. private _useAlphaFromDiffuseTexture;
  29406. /**
  29407. * Does the transparency come from the diffuse texture alpha channel.
  29408. */
  29409. useAlphaFromDiffuseTexture: boolean;
  29410. private _useEmissiveAsIllumination;
  29411. /**
  29412. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  29413. */
  29414. useEmissiveAsIllumination: boolean;
  29415. private _linkEmissiveWithDiffuse;
  29416. /**
  29417. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  29418. * the emissive level when the final color is close to one.
  29419. */
  29420. linkEmissiveWithDiffuse: boolean;
  29421. private _useSpecularOverAlpha;
  29422. /**
  29423. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  29424. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  29425. */
  29426. useSpecularOverAlpha: boolean;
  29427. private _useReflectionOverAlpha;
  29428. /**
  29429. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  29430. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  29431. */
  29432. useReflectionOverAlpha: boolean;
  29433. private _disableLighting;
  29434. /**
  29435. * Does lights from the scene impacts this material.
  29436. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  29437. */
  29438. disableLighting: boolean;
  29439. private _useObjectSpaceNormalMap;
  29440. /**
  29441. * Allows using an object space normal map (instead of tangent space).
  29442. */
  29443. useObjectSpaceNormalMap: boolean;
  29444. private _useParallax;
  29445. /**
  29446. * Is parallax enabled or not.
  29447. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  29448. */
  29449. useParallax: boolean;
  29450. private _useParallaxOcclusion;
  29451. /**
  29452. * Is parallax occlusion enabled or not.
  29453. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  29454. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  29455. */
  29456. useParallaxOcclusion: boolean;
  29457. /**
  29458. * 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.
  29459. */
  29460. parallaxScaleBias: number;
  29461. private _roughness;
  29462. /**
  29463. * Helps to define how blurry the reflections should appears in the material.
  29464. */
  29465. roughness: number;
  29466. /**
  29467. * In case of refraction, define the value of the index of refraction.
  29468. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29469. */
  29470. indexOfRefraction: number;
  29471. /**
  29472. * Invert the refraction texture alongside the y axis.
  29473. * It can be useful with procedural textures or probe for instance.
  29474. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29475. */
  29476. invertRefractionY: boolean;
  29477. /**
  29478. * Defines the alpha limits in alpha test mode.
  29479. */
  29480. alphaCutOff: number;
  29481. private _useLightmapAsShadowmap;
  29482. /**
  29483. * In case of light mapping, define whether the map contains light or shadow informations.
  29484. */
  29485. useLightmapAsShadowmap: boolean;
  29486. private _diffuseFresnelParameters;
  29487. /**
  29488. * Define the diffuse fresnel parameters of the material.
  29489. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29490. */
  29491. diffuseFresnelParameters: FresnelParameters;
  29492. private _opacityFresnelParameters;
  29493. /**
  29494. * Define the opacity fresnel parameters of the material.
  29495. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29496. */
  29497. opacityFresnelParameters: FresnelParameters;
  29498. private _reflectionFresnelParameters;
  29499. /**
  29500. * Define the reflection fresnel parameters of the material.
  29501. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29502. */
  29503. reflectionFresnelParameters: FresnelParameters;
  29504. private _refractionFresnelParameters;
  29505. /**
  29506. * Define the refraction fresnel parameters of the material.
  29507. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29508. */
  29509. refractionFresnelParameters: FresnelParameters;
  29510. private _emissiveFresnelParameters;
  29511. /**
  29512. * Define the emissive fresnel parameters of the material.
  29513. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29514. */
  29515. emissiveFresnelParameters: FresnelParameters;
  29516. private _useReflectionFresnelFromSpecular;
  29517. /**
  29518. * If true automatically deducts the fresnels values from the material specularity.
  29519. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29520. */
  29521. useReflectionFresnelFromSpecular: boolean;
  29522. private _useGlossinessFromSpecularMapAlpha;
  29523. /**
  29524. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  29525. */
  29526. useGlossinessFromSpecularMapAlpha: boolean;
  29527. private _maxSimultaneousLights;
  29528. /**
  29529. * Defines the maximum number of lights that can be used in the material
  29530. */
  29531. maxSimultaneousLights: number;
  29532. private _invertNormalMapX;
  29533. /**
  29534. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  29535. */
  29536. invertNormalMapX: boolean;
  29537. private _invertNormalMapY;
  29538. /**
  29539. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  29540. */
  29541. invertNormalMapY: boolean;
  29542. private _twoSidedLighting;
  29543. /**
  29544. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  29545. */
  29546. twoSidedLighting: boolean;
  29547. /**
  29548. * Default configuration related to image processing available in the standard Material.
  29549. */
  29550. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  29551. /**
  29552. * Gets the image processing configuration used either in this material.
  29553. */
  29554. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  29555. /**
  29556. * Sets the Default image processing configuration used either in the this material.
  29557. *
  29558. * If sets to null, the scene one is in use.
  29559. */
  29560. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  29561. /**
  29562. * Keep track of the image processing observer to allow dispose and replace.
  29563. */
  29564. private _imageProcessingObserver;
  29565. /**
  29566. * Attaches a new image processing configuration to the Standard Material.
  29567. * @param configuration
  29568. */
  29569. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  29570. /**
  29571. * Gets wether the color curves effect is enabled.
  29572. */
  29573. get cameraColorCurvesEnabled(): boolean;
  29574. /**
  29575. * Sets wether the color curves effect is enabled.
  29576. */
  29577. set cameraColorCurvesEnabled(value: boolean);
  29578. /**
  29579. * Gets wether the color grading effect is enabled.
  29580. */
  29581. get cameraColorGradingEnabled(): boolean;
  29582. /**
  29583. * Gets wether the color grading effect is enabled.
  29584. */
  29585. set cameraColorGradingEnabled(value: boolean);
  29586. /**
  29587. * Gets wether tonemapping is enabled or not.
  29588. */
  29589. get cameraToneMappingEnabled(): boolean;
  29590. /**
  29591. * Sets wether tonemapping is enabled or not
  29592. */
  29593. set cameraToneMappingEnabled(value: boolean);
  29594. /**
  29595. * The camera exposure used on this material.
  29596. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  29597. * This corresponds to a photographic exposure.
  29598. */
  29599. get cameraExposure(): number;
  29600. /**
  29601. * The camera exposure used on this material.
  29602. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  29603. * This corresponds to a photographic exposure.
  29604. */
  29605. set cameraExposure(value: number);
  29606. /**
  29607. * Gets The camera contrast used on this material.
  29608. */
  29609. get cameraContrast(): number;
  29610. /**
  29611. * Sets The camera contrast used on this material.
  29612. */
  29613. set cameraContrast(value: number);
  29614. /**
  29615. * Gets the Color Grading 2D Lookup Texture.
  29616. */
  29617. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  29618. /**
  29619. * Sets the Color Grading 2D Lookup Texture.
  29620. */
  29621. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  29622. /**
  29623. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29624. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29625. * 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;
  29626. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29627. */
  29628. get cameraColorCurves(): Nullable<ColorCurves>;
  29629. /**
  29630. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29631. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29632. * 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;
  29633. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29634. */
  29635. set cameraColorCurves(value: Nullable<ColorCurves>);
  29636. protected _renderTargets: SmartArray<RenderTargetTexture>;
  29637. protected _worldViewProjectionMatrix: Matrix;
  29638. protected _globalAmbientColor: Color3;
  29639. protected _useLogarithmicDepth: boolean;
  29640. protected _rebuildInParallel: boolean;
  29641. /**
  29642. * Instantiates a new standard material.
  29643. * This is the default material used in Babylon. It is the best trade off between quality
  29644. * and performances.
  29645. * @see http://doc.babylonjs.com/babylon101/materials
  29646. * @param name Define the name of the material in the scene
  29647. * @param scene Define the scene the material belong to
  29648. */
  29649. constructor(name: string, scene: Scene);
  29650. /**
  29651. * Gets a boolean indicating that current material needs to register RTT
  29652. */
  29653. get hasRenderTargetTextures(): boolean;
  29654. /**
  29655. * Gets the current class name of the material e.g. "StandardMaterial"
  29656. * Mainly use in serialization.
  29657. * @returns the class name
  29658. */
  29659. getClassName(): string;
  29660. /**
  29661. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  29662. * You can try switching to logarithmic depth.
  29663. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  29664. */
  29665. get useLogarithmicDepth(): boolean;
  29666. set useLogarithmicDepth(value: boolean);
  29667. /**
  29668. * Specifies if the material will require alpha blending
  29669. * @returns a boolean specifying if alpha blending is needed
  29670. */
  29671. needAlphaBlending(): boolean;
  29672. /**
  29673. * Specifies if this material should be rendered in alpha test mode
  29674. * @returns a boolean specifying if an alpha test is needed.
  29675. */
  29676. needAlphaTesting(): boolean;
  29677. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  29678. /**
  29679. * Get the texture used for alpha test purpose.
  29680. * @returns the diffuse texture in case of the standard material.
  29681. */
  29682. getAlphaTestTexture(): Nullable<BaseTexture>;
  29683. /**
  29684. * Get if the submesh is ready to be used and all its information available.
  29685. * Child classes can use it to update shaders
  29686. * @param mesh defines the mesh to check
  29687. * @param subMesh defines which submesh to check
  29688. * @param useInstances specifies that instances should be used
  29689. * @returns a boolean indicating that the submesh is ready or not
  29690. */
  29691. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29692. /**
  29693. * Builds the material UBO layouts.
  29694. * Used internally during the effect preparation.
  29695. */
  29696. buildUniformLayout(): void;
  29697. /**
  29698. * Unbinds the material from the mesh
  29699. */
  29700. unbind(): void;
  29701. /**
  29702. * Binds the submesh to this material by preparing the effect and shader to draw
  29703. * @param world defines the world transformation matrix
  29704. * @param mesh defines the mesh containing the submesh
  29705. * @param subMesh defines the submesh to bind the material to
  29706. */
  29707. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29708. /**
  29709. * Get the list of animatables in the material.
  29710. * @returns the list of animatables object used in the material
  29711. */
  29712. getAnimatables(): IAnimatable[];
  29713. /**
  29714. * Gets the active textures from the material
  29715. * @returns an array of textures
  29716. */
  29717. getActiveTextures(): BaseTexture[];
  29718. /**
  29719. * Specifies if the material uses a texture
  29720. * @param texture defines the texture to check against the material
  29721. * @returns a boolean specifying if the material uses the texture
  29722. */
  29723. hasTexture(texture: BaseTexture): boolean;
  29724. /**
  29725. * Disposes the material
  29726. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29727. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29728. */
  29729. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  29730. /**
  29731. * Makes a duplicate of the material, and gives it a new name
  29732. * @param name defines the new name for the duplicated material
  29733. * @returns the cloned material
  29734. */
  29735. clone(name: string): StandardMaterial;
  29736. /**
  29737. * Serializes this material in a JSON representation
  29738. * @returns the serialized material object
  29739. */
  29740. serialize(): any;
  29741. /**
  29742. * Creates a standard material from parsed material data
  29743. * @param source defines the JSON representation of the material
  29744. * @param scene defines the hosting scene
  29745. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29746. * @returns a new standard material
  29747. */
  29748. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  29749. /**
  29750. * Are diffuse textures enabled in the application.
  29751. */
  29752. static get DiffuseTextureEnabled(): boolean;
  29753. static set DiffuseTextureEnabled(value: boolean);
  29754. /**
  29755. * Are ambient textures enabled in the application.
  29756. */
  29757. static get AmbientTextureEnabled(): boolean;
  29758. static set AmbientTextureEnabled(value: boolean);
  29759. /**
  29760. * Are opacity textures enabled in the application.
  29761. */
  29762. static get OpacityTextureEnabled(): boolean;
  29763. static set OpacityTextureEnabled(value: boolean);
  29764. /**
  29765. * Are reflection textures enabled in the application.
  29766. */
  29767. static get ReflectionTextureEnabled(): boolean;
  29768. static set ReflectionTextureEnabled(value: boolean);
  29769. /**
  29770. * Are emissive textures enabled in the application.
  29771. */
  29772. static get EmissiveTextureEnabled(): boolean;
  29773. static set EmissiveTextureEnabled(value: boolean);
  29774. /**
  29775. * Are specular textures enabled in the application.
  29776. */
  29777. static get SpecularTextureEnabled(): boolean;
  29778. static set SpecularTextureEnabled(value: boolean);
  29779. /**
  29780. * Are bump textures enabled in the application.
  29781. */
  29782. static get BumpTextureEnabled(): boolean;
  29783. static set BumpTextureEnabled(value: boolean);
  29784. /**
  29785. * Are lightmap textures enabled in the application.
  29786. */
  29787. static get LightmapTextureEnabled(): boolean;
  29788. static set LightmapTextureEnabled(value: boolean);
  29789. /**
  29790. * Are refraction textures enabled in the application.
  29791. */
  29792. static get RefractionTextureEnabled(): boolean;
  29793. static set RefractionTextureEnabled(value: boolean);
  29794. /**
  29795. * Are color grading textures enabled in the application.
  29796. */
  29797. static get ColorGradingTextureEnabled(): boolean;
  29798. static set ColorGradingTextureEnabled(value: boolean);
  29799. /**
  29800. * Are fresnels enabled in the application.
  29801. */
  29802. static get FresnelEnabled(): boolean;
  29803. static set FresnelEnabled(value: boolean);
  29804. }
  29805. }
  29806. declare module BABYLON {
  29807. /**
  29808. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  29809. *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.
  29810. * The SPS is also a particle system. It provides some methods to manage the particles.
  29811. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  29812. *
  29813. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  29814. */
  29815. export class SolidParticleSystem implements IDisposable {
  29816. /**
  29817. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  29818. * Example : var p = SPS.particles[i];
  29819. */
  29820. particles: SolidParticle[];
  29821. /**
  29822. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  29823. */
  29824. nbParticles: number;
  29825. /**
  29826. * If the particles must ever face the camera (default false). Useful for planar particles.
  29827. */
  29828. billboard: boolean;
  29829. /**
  29830. * Recompute normals when adding a shape
  29831. */
  29832. recomputeNormals: boolean;
  29833. /**
  29834. * This a counter ofr your own usage. It's not set by any SPS functions.
  29835. */
  29836. counter: number;
  29837. /**
  29838. * The SPS name. This name is also given to the underlying mesh.
  29839. */
  29840. name: string;
  29841. /**
  29842. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  29843. */
  29844. mesh: Mesh;
  29845. /**
  29846. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  29847. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  29848. */
  29849. vars: any;
  29850. /**
  29851. * This array is populated when the SPS is set as 'pickable'.
  29852. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  29853. * Each element of this array is an object `{idx: int, faceId: int}`.
  29854. * `idx` is the picked particle index in the `SPS.particles` array
  29855. * `faceId` is the picked face index counted within this particle.
  29856. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  29857. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  29858. * Use the method SPS.pickedParticle(pickingInfo) instead.
  29859. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  29860. */
  29861. pickedParticles: {
  29862. idx: number;
  29863. faceId: number;
  29864. }[];
  29865. /**
  29866. * This array is populated when the SPS is set as 'pickable'
  29867. * Each key of this array is a submesh index.
  29868. * Each element of this array is a second array defined like this :
  29869. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  29870. * Each element of this second array is an object `{idx: int, faceId: int}`.
  29871. * `idx` is the picked particle index in the `SPS.particles` array
  29872. * `faceId` is the picked face index counted within this particle.
  29873. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  29874. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  29875. */
  29876. pickedBySubMesh: {
  29877. idx: number;
  29878. faceId: number;
  29879. }[][];
  29880. /**
  29881. * This array is populated when `enableDepthSort` is set to true.
  29882. * Each element of this array is an instance of the class DepthSortedParticle.
  29883. */
  29884. depthSortedParticles: DepthSortedParticle[];
  29885. /**
  29886. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  29887. * @hidden
  29888. */
  29889. _bSphereOnly: boolean;
  29890. /**
  29891. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  29892. * @hidden
  29893. */
  29894. _bSphereRadiusFactor: number;
  29895. private _scene;
  29896. private _positions;
  29897. private _indices;
  29898. private _normals;
  29899. private _colors;
  29900. private _uvs;
  29901. private _indices32;
  29902. private _positions32;
  29903. private _normals32;
  29904. private _fixedNormal32;
  29905. private _colors32;
  29906. private _uvs32;
  29907. private _index;
  29908. private _updatable;
  29909. private _pickable;
  29910. private _isVisibilityBoxLocked;
  29911. private _alwaysVisible;
  29912. private _depthSort;
  29913. private _expandable;
  29914. private _shapeCounter;
  29915. private _copy;
  29916. private _color;
  29917. private _computeParticleColor;
  29918. private _computeParticleTexture;
  29919. private _computeParticleRotation;
  29920. private _computeParticleVertex;
  29921. private _computeBoundingBox;
  29922. private _depthSortParticles;
  29923. private _camera;
  29924. private _mustUnrotateFixedNormals;
  29925. private _particlesIntersect;
  29926. private _needs32Bits;
  29927. private _isNotBuilt;
  29928. private _lastParticleId;
  29929. private _idxOfId;
  29930. private _multimaterialEnabled;
  29931. private _useModelMaterial;
  29932. private _indicesByMaterial;
  29933. private _materialIndexes;
  29934. private _depthSortFunction;
  29935. private _materialSortFunction;
  29936. private _materials;
  29937. private _multimaterial;
  29938. private _materialIndexesById;
  29939. private _defaultMaterial;
  29940. private _autoUpdateSubMeshes;
  29941. private _tmpVertex;
  29942. /**
  29943. * Creates a SPS (Solid Particle System) object.
  29944. * @param name (String) is the SPS name, this will be the underlying mesh name.
  29945. * @param scene (Scene) is the scene in which the SPS is added.
  29946. * @param options defines the options of the sps e.g.
  29947. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  29948. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  29949. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  29950. * * 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.
  29951. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  29952. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  29953. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  29954. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  29955. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  29956. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  29957. */
  29958. constructor(name: string, scene: Scene, options?: {
  29959. updatable?: boolean;
  29960. isPickable?: boolean;
  29961. enableDepthSort?: boolean;
  29962. particleIntersection?: boolean;
  29963. boundingSphereOnly?: boolean;
  29964. bSphereRadiusFactor?: number;
  29965. expandable?: boolean;
  29966. useModelMaterial?: boolean;
  29967. enableMultiMaterial?: boolean;
  29968. });
  29969. /**
  29970. * Builds the SPS underlying mesh. Returns a standard Mesh.
  29971. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  29972. * @returns the created mesh
  29973. */
  29974. buildMesh(): Mesh;
  29975. /**
  29976. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  29977. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  29978. * Thus the particles generated from `digest()` have their property `position` set yet.
  29979. * @param mesh ( Mesh ) is the mesh to be digested
  29980. * @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
  29981. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  29982. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  29983. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  29984. * @returns the current SPS
  29985. */
  29986. digest(mesh: Mesh, options?: {
  29987. facetNb?: number;
  29988. number?: number;
  29989. delta?: number;
  29990. storage?: [];
  29991. }): SolidParticleSystem;
  29992. /**
  29993. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  29994. * @hidden
  29995. */
  29996. private _unrotateFixedNormals;
  29997. /**
  29998. * Resets the temporary working copy particle
  29999. * @hidden
  30000. */
  30001. private _resetCopy;
  30002. /**
  30003. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  30004. * @param p the current index in the positions array to be updated
  30005. * @param ind the current index in the indices array
  30006. * @param shape a Vector3 array, the shape geometry
  30007. * @param positions the positions array to be updated
  30008. * @param meshInd the shape indices array
  30009. * @param indices the indices array to be updated
  30010. * @param meshUV the shape uv array
  30011. * @param uvs the uv array to be updated
  30012. * @param meshCol the shape color array
  30013. * @param colors the color array to be updated
  30014. * @param meshNor the shape normals array
  30015. * @param normals the normals array to be updated
  30016. * @param idx the particle index
  30017. * @param idxInShape the particle index in its shape
  30018. * @param options the addShape() method passed options
  30019. * @model the particle model
  30020. * @hidden
  30021. */
  30022. private _meshBuilder;
  30023. /**
  30024. * Returns a shape Vector3 array from positions float array
  30025. * @param positions float array
  30026. * @returns a vector3 array
  30027. * @hidden
  30028. */
  30029. private _posToShape;
  30030. /**
  30031. * Returns a shapeUV array from a float uvs (array deep copy)
  30032. * @param uvs as a float array
  30033. * @returns a shapeUV array
  30034. * @hidden
  30035. */
  30036. private _uvsToShapeUV;
  30037. /**
  30038. * Adds a new particle object in the particles array
  30039. * @param idx particle index in particles array
  30040. * @param id particle id
  30041. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  30042. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  30043. * @param model particle ModelShape object
  30044. * @param shapeId model shape identifier
  30045. * @param idxInShape index of the particle in the current model
  30046. * @param bInfo model bounding info object
  30047. * @param storage target storage array, if any
  30048. * @hidden
  30049. */
  30050. private _addParticle;
  30051. /**
  30052. * Adds some particles to the SPS from the model shape. Returns the shape id.
  30053. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  30054. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  30055. * @param nb (positive integer) the number of particles to be created from this model
  30056. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  30057. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  30058. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  30059. * @returns the number of shapes in the system
  30060. */
  30061. addShape(mesh: Mesh, nb: number, options?: {
  30062. positionFunction?: any;
  30063. vertexFunction?: any;
  30064. storage?: [];
  30065. }): number;
  30066. /**
  30067. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  30068. * @hidden
  30069. */
  30070. private _rebuildParticle;
  30071. /**
  30072. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  30073. * @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.
  30074. * @returns the SPS.
  30075. */
  30076. rebuildMesh(reset?: boolean): SolidParticleSystem;
  30077. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  30078. * Returns an array with the removed particles.
  30079. * 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.
  30080. * The SPS can't be empty so at least one particle needs to remain in place.
  30081. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  30082. * @param start index of the first particle to remove
  30083. * @param end index of the last particle to remove (included)
  30084. * @returns an array populated with the removed particles
  30085. */
  30086. removeParticles(start: number, end: number): SolidParticle[];
  30087. /**
  30088. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  30089. * @param solidParticleArray an array populated with Solid Particles objects
  30090. * @returns the SPS
  30091. */
  30092. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  30093. /**
  30094. * Creates a new particle and modifies the SPS mesh geometry :
  30095. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  30096. * - calls _addParticle() to populate the particle array
  30097. * factorized code from addShape() and insertParticlesFromArray()
  30098. * @param idx particle index in the particles array
  30099. * @param i particle index in its shape
  30100. * @param modelShape particle ModelShape object
  30101. * @param shape shape vertex array
  30102. * @param meshInd shape indices array
  30103. * @param meshUV shape uv array
  30104. * @param meshCol shape color array
  30105. * @param meshNor shape normals array
  30106. * @param bbInfo shape bounding info
  30107. * @param storage target particle storage
  30108. * @options addShape() passed options
  30109. * @hidden
  30110. */
  30111. private _insertNewParticle;
  30112. /**
  30113. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  30114. * This method calls `updateParticle()` for each particle of the SPS.
  30115. * For an animated SPS, it is usually called within the render loop.
  30116. * 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.
  30117. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  30118. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  30119. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  30120. * @returns the SPS.
  30121. */
  30122. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  30123. /**
  30124. * Disposes the SPS.
  30125. */
  30126. dispose(): void;
  30127. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  30128. * idx is the particle index in the SPS
  30129. * faceId is the picked face index counted within this particle.
  30130. * Returns null if the pickInfo can't identify a picked particle.
  30131. * @param pickingInfo (PickingInfo object)
  30132. * @returns {idx: number, faceId: number} or null
  30133. */
  30134. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  30135. idx: number;
  30136. faceId: number;
  30137. }>;
  30138. /**
  30139. * Returns a SolidParticle object from its identifier : particle.id
  30140. * @param id (integer) the particle Id
  30141. * @returns the searched particle or null if not found in the SPS.
  30142. */
  30143. getParticleById(id: number): Nullable<SolidParticle>;
  30144. /**
  30145. * Returns a new array populated with the particles having the passed shapeId.
  30146. * @param shapeId (integer) the shape identifier
  30147. * @returns a new solid particle array
  30148. */
  30149. getParticlesByShapeId(shapeId: number): SolidParticle[];
  30150. /**
  30151. * Populates the passed array "ref" with the particles having the passed shapeId.
  30152. * @param shapeId the shape identifier
  30153. * @returns the SPS
  30154. * @param ref
  30155. */
  30156. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  30157. /**
  30158. * Computes the required SubMeshes according the materials assigned to the particles.
  30159. * @returns the solid particle system.
  30160. * Does nothing if called before the SPS mesh is built.
  30161. */
  30162. computeSubMeshes(): SolidParticleSystem;
  30163. /**
  30164. * Sorts the solid particles by material when MultiMaterial is enabled.
  30165. * Updates the indices32 array.
  30166. * Updates the indicesByMaterial array.
  30167. * Updates the mesh indices array.
  30168. * @returns the SPS
  30169. * @hidden
  30170. */
  30171. private _sortParticlesByMaterial;
  30172. /**
  30173. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  30174. * @hidden
  30175. */
  30176. private _setMaterialIndexesById;
  30177. /**
  30178. * Returns an array with unique values of Materials from the passed array
  30179. * @param array the material array to be checked and filtered
  30180. * @hidden
  30181. */
  30182. private _filterUniqueMaterialId;
  30183. /**
  30184. * Sets a new Standard Material as _defaultMaterial if not already set.
  30185. * @hidden
  30186. */
  30187. private _setDefaultMaterial;
  30188. /**
  30189. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  30190. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30191. * @returns the SPS.
  30192. */
  30193. refreshVisibleSize(): SolidParticleSystem;
  30194. /**
  30195. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  30196. * @param size the size (float) of the visibility box
  30197. * note : this doesn't lock the SPS mesh bounding box.
  30198. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30199. */
  30200. setVisibilityBox(size: number): void;
  30201. /**
  30202. * Gets whether the SPS as always visible or not
  30203. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30204. */
  30205. get isAlwaysVisible(): boolean;
  30206. /**
  30207. * Sets the SPS as always visible or not
  30208. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30209. */
  30210. set isAlwaysVisible(val: boolean);
  30211. /**
  30212. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  30213. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30214. */
  30215. set isVisibilityBoxLocked(val: boolean);
  30216. /**
  30217. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  30218. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30219. */
  30220. get isVisibilityBoxLocked(): boolean;
  30221. /**
  30222. * Tells to `setParticles()` to compute the particle rotations or not.
  30223. * Default value : true. The SPS is faster when it's set to false.
  30224. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  30225. */
  30226. set computeParticleRotation(val: boolean);
  30227. /**
  30228. * Tells to `setParticles()` to compute the particle colors or not.
  30229. * Default value : true. The SPS is faster when it's set to false.
  30230. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  30231. */
  30232. set computeParticleColor(val: boolean);
  30233. set computeParticleTexture(val: boolean);
  30234. /**
  30235. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  30236. * Default value : false. The SPS is faster when it's set to false.
  30237. * Note : the particle custom vertex positions aren't stored values.
  30238. */
  30239. set computeParticleVertex(val: boolean);
  30240. /**
  30241. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  30242. */
  30243. set computeBoundingBox(val: boolean);
  30244. /**
  30245. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  30246. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  30247. * Default : `true`
  30248. */
  30249. set depthSortParticles(val: boolean);
  30250. /**
  30251. * Gets if `setParticles()` computes the particle rotations or not.
  30252. * Default value : true. The SPS is faster when it's set to false.
  30253. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  30254. */
  30255. get computeParticleRotation(): boolean;
  30256. /**
  30257. * Gets if `setParticles()` computes the particle colors or not.
  30258. * Default value : true. The SPS is faster when it's set to false.
  30259. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  30260. */
  30261. get computeParticleColor(): boolean;
  30262. /**
  30263. * Gets if `setParticles()` computes the particle textures or not.
  30264. * Default value : true. The SPS is faster when it's set to false.
  30265. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  30266. */
  30267. get computeParticleTexture(): boolean;
  30268. /**
  30269. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  30270. * Default value : false. The SPS is faster when it's set to false.
  30271. * Note : the particle custom vertex positions aren't stored values.
  30272. */
  30273. get computeParticleVertex(): boolean;
  30274. /**
  30275. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  30276. */
  30277. get computeBoundingBox(): boolean;
  30278. /**
  30279. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  30280. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  30281. * Default : `true`
  30282. */
  30283. get depthSortParticles(): boolean;
  30284. /**
  30285. * Gets if the SPS is created as expandable at construction time.
  30286. * Default : `false`
  30287. */
  30288. get expandable(): boolean;
  30289. /**
  30290. * Gets if the SPS supports the Multi Materials
  30291. */
  30292. get multimaterialEnabled(): boolean;
  30293. /**
  30294. * Gets if the SPS uses the model materials for its own multimaterial.
  30295. */
  30296. get useModelMaterial(): boolean;
  30297. /**
  30298. * The SPS used material array.
  30299. */
  30300. get materials(): Material[];
  30301. /**
  30302. * Sets the SPS MultiMaterial from the passed materials.
  30303. * Note : the passed array is internally copied and not used then by reference.
  30304. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  30305. */
  30306. setMultiMaterial(materials: Material[]): void;
  30307. /**
  30308. * The SPS computed multimaterial object
  30309. */
  30310. get multimaterial(): MultiMaterial;
  30311. set multimaterial(mm: MultiMaterial);
  30312. /**
  30313. * If the subMeshes must be updated on the next call to setParticles()
  30314. */
  30315. get autoUpdateSubMeshes(): boolean;
  30316. set autoUpdateSubMeshes(val: boolean);
  30317. /**
  30318. * This function does nothing. It may be overwritten to set all the particle first values.
  30319. * The SPS doesn't call this function, you may have to call it by your own.
  30320. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30321. */
  30322. initParticles(): void;
  30323. /**
  30324. * This function does nothing. It may be overwritten to recycle a particle.
  30325. * The SPS doesn't call this function, you may have to call it by your own.
  30326. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30327. * @param particle The particle to recycle
  30328. * @returns the recycled particle
  30329. */
  30330. recycleParticle(particle: SolidParticle): SolidParticle;
  30331. /**
  30332. * Updates a particle : this function should be overwritten by the user.
  30333. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  30334. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30335. * @example : just set a particle position or velocity and recycle conditions
  30336. * @param particle The particle to update
  30337. * @returns the updated particle
  30338. */
  30339. updateParticle(particle: SolidParticle): SolidParticle;
  30340. /**
  30341. * Updates a vertex of a particle : it can be overwritten by the user.
  30342. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  30343. * @param particle the current particle
  30344. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  30345. * @param pt the index of the current vertex in the particle shape
  30346. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  30347. * @example : just set a vertex particle position or color
  30348. * @returns the sps
  30349. */
  30350. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  30351. /**
  30352. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  30353. * This does nothing and may be overwritten by the user.
  30354. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30355. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30356. * @param update the boolean update value actually passed to setParticles()
  30357. */
  30358. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  30359. /**
  30360. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  30361. * This will be passed three parameters.
  30362. * This does nothing and may be overwritten by the user.
  30363. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30364. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30365. * @param update the boolean update value actually passed to setParticles()
  30366. */
  30367. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  30368. }
  30369. }
  30370. declare module BABYLON {
  30371. /**
  30372. * Represents one particle of a solid particle system.
  30373. */
  30374. export class SolidParticle {
  30375. /**
  30376. * particle global index
  30377. */
  30378. idx: number;
  30379. /**
  30380. * particle identifier
  30381. */
  30382. id: number;
  30383. /**
  30384. * The color of the particle
  30385. */
  30386. color: Nullable<Color4>;
  30387. /**
  30388. * The world space position of the particle.
  30389. */
  30390. position: Vector3;
  30391. /**
  30392. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  30393. */
  30394. rotation: Vector3;
  30395. /**
  30396. * The world space rotation quaternion of the particle.
  30397. */
  30398. rotationQuaternion: Nullable<Quaternion>;
  30399. /**
  30400. * The scaling of the particle.
  30401. */
  30402. scaling: Vector3;
  30403. /**
  30404. * The uvs of the particle.
  30405. */
  30406. uvs: Vector4;
  30407. /**
  30408. * The current speed of the particle.
  30409. */
  30410. velocity: Vector3;
  30411. /**
  30412. * The pivot point in the particle local space.
  30413. */
  30414. pivot: Vector3;
  30415. /**
  30416. * Must the particle be translated from its pivot point in its local space ?
  30417. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  30418. * Default : false
  30419. */
  30420. translateFromPivot: boolean;
  30421. /**
  30422. * Is the particle active or not ?
  30423. */
  30424. alive: boolean;
  30425. /**
  30426. * Is the particle visible or not ?
  30427. */
  30428. isVisible: boolean;
  30429. /**
  30430. * Index of this particle in the global "positions" array (Internal use)
  30431. * @hidden
  30432. */
  30433. _pos: number;
  30434. /**
  30435. * @hidden Index of this particle in the global "indices" array (Internal use)
  30436. */
  30437. _ind: number;
  30438. /**
  30439. * @hidden ModelShape of this particle (Internal use)
  30440. */
  30441. _model: ModelShape;
  30442. /**
  30443. * ModelShape id of this particle
  30444. */
  30445. shapeId: number;
  30446. /**
  30447. * Index of the particle in its shape id
  30448. */
  30449. idxInShape: number;
  30450. /**
  30451. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  30452. */
  30453. _modelBoundingInfo: BoundingInfo;
  30454. /**
  30455. * @hidden Particle BoundingInfo object (Internal use)
  30456. */
  30457. _boundingInfo: BoundingInfo;
  30458. /**
  30459. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  30460. */
  30461. _sps: SolidParticleSystem;
  30462. /**
  30463. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  30464. */
  30465. _stillInvisible: boolean;
  30466. /**
  30467. * @hidden Last computed particle rotation matrix
  30468. */
  30469. _rotationMatrix: number[];
  30470. /**
  30471. * Parent particle Id, if any.
  30472. * Default null.
  30473. */
  30474. parentId: Nullable<number>;
  30475. /**
  30476. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  30477. */
  30478. materialIndex: Nullable<number>;
  30479. /**
  30480. * Custom object or properties.
  30481. */
  30482. props: Nullable<any>;
  30483. /**
  30484. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  30485. * The possible values are :
  30486. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  30487. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30488. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  30489. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  30490. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30491. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  30492. * */
  30493. cullingStrategy: number;
  30494. /**
  30495. * @hidden Internal global position in the SPS.
  30496. */
  30497. _globalPosition: Vector3;
  30498. /**
  30499. * Creates a Solid Particle object.
  30500. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  30501. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  30502. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  30503. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  30504. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  30505. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  30506. * @param shapeId (integer) is the model shape identifier in the SPS.
  30507. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  30508. * @param sps defines the sps it is associated to
  30509. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  30510. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  30511. */
  30512. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  30513. /**
  30514. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  30515. * @param target the particle target
  30516. * @returns the current particle
  30517. */
  30518. copyToRef(target: SolidParticle): SolidParticle;
  30519. /**
  30520. * Legacy support, changed scale to scaling
  30521. */
  30522. get scale(): Vector3;
  30523. /**
  30524. * Legacy support, changed scale to scaling
  30525. */
  30526. set scale(scale: Vector3);
  30527. /**
  30528. * Legacy support, changed quaternion to rotationQuaternion
  30529. */
  30530. get quaternion(): Nullable<Quaternion>;
  30531. /**
  30532. * Legacy support, changed quaternion to rotationQuaternion
  30533. */
  30534. set quaternion(q: Nullable<Quaternion>);
  30535. /**
  30536. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  30537. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  30538. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  30539. * @returns true if it intersects
  30540. */
  30541. intersectsMesh(target: Mesh | SolidParticle): boolean;
  30542. /**
  30543. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  30544. * A particle is in the frustum if its bounding box intersects the frustum
  30545. * @param frustumPlanes defines the frustum to test
  30546. * @returns true if the particle is in the frustum planes
  30547. */
  30548. isInFrustum(frustumPlanes: Plane[]): boolean;
  30549. /**
  30550. * get the rotation matrix of the particle
  30551. * @hidden
  30552. */
  30553. getRotationMatrix(m: Matrix): void;
  30554. }
  30555. /**
  30556. * Represents the shape of the model used by one particle of a solid particle system.
  30557. * SPS internal tool, don't use it manually.
  30558. */
  30559. export class ModelShape {
  30560. /**
  30561. * The shape id
  30562. * @hidden
  30563. */
  30564. shapeID: number;
  30565. /**
  30566. * flat array of model positions (internal use)
  30567. * @hidden
  30568. */
  30569. _shape: Vector3[];
  30570. /**
  30571. * flat array of model UVs (internal use)
  30572. * @hidden
  30573. */
  30574. _shapeUV: number[];
  30575. /**
  30576. * color array of the model
  30577. * @hidden
  30578. */
  30579. _shapeColors: number[];
  30580. /**
  30581. * indices array of the model
  30582. * @hidden
  30583. */
  30584. _indices: number[];
  30585. /**
  30586. * normals array of the model
  30587. * @hidden
  30588. */
  30589. _normals: number[];
  30590. /**
  30591. * length of the shape in the model indices array (internal use)
  30592. * @hidden
  30593. */
  30594. _indicesLength: number;
  30595. /**
  30596. * Custom position function (internal use)
  30597. * @hidden
  30598. */
  30599. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  30600. /**
  30601. * Custom vertex function (internal use)
  30602. * @hidden
  30603. */
  30604. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  30605. /**
  30606. * Model material (internal use)
  30607. * @hidden
  30608. */
  30609. _material: Nullable<Material>;
  30610. /**
  30611. * 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.
  30612. * SPS internal tool, don't use it manually.
  30613. * @hidden
  30614. */
  30615. 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>);
  30616. }
  30617. /**
  30618. * Represents a Depth Sorted Particle in the solid particle system.
  30619. * @hidden
  30620. */
  30621. export class DepthSortedParticle {
  30622. /**
  30623. * Particle index
  30624. */
  30625. idx: number;
  30626. /**
  30627. * Index of the particle in the "indices" array
  30628. */
  30629. ind: number;
  30630. /**
  30631. * Length of the particle shape in the "indices" array
  30632. */
  30633. indicesLength: number;
  30634. /**
  30635. * Squared distance from the particle to the camera
  30636. */
  30637. sqDistance: number;
  30638. /**
  30639. * Material index when used with MultiMaterials
  30640. */
  30641. materialIndex: number;
  30642. /**
  30643. * Creates a new sorted particle
  30644. * @param materialIndex
  30645. */
  30646. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  30647. }
  30648. /**
  30649. * Represents a solid particle vertex
  30650. */
  30651. export class SolidParticleVertex {
  30652. /**
  30653. * Vertex position
  30654. */
  30655. position: Vector3;
  30656. /**
  30657. * Vertex color
  30658. */
  30659. color: Color4;
  30660. /**
  30661. * Vertex UV
  30662. */
  30663. uv: Vector2;
  30664. /**
  30665. * Creates a new solid particle vertex
  30666. */
  30667. constructor();
  30668. /** Vertex x coordinate */
  30669. get x(): number;
  30670. set x(val: number);
  30671. /** Vertex y coordinate */
  30672. get y(): number;
  30673. set y(val: number);
  30674. /** Vertex z coordinate */
  30675. get z(): number;
  30676. set z(val: number);
  30677. }
  30678. }
  30679. declare module BABYLON {
  30680. /**
  30681. * @hidden
  30682. */
  30683. export class _MeshCollisionData {
  30684. _checkCollisions: boolean;
  30685. _collisionMask: number;
  30686. _collisionGroup: number;
  30687. _surroundingMeshes: Nullable<AbstractMesh[]>;
  30688. _collider: Nullable<Collider>;
  30689. _oldPositionForCollisions: Vector3;
  30690. _diffPositionForCollisions: Vector3;
  30691. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  30692. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  30693. }
  30694. }
  30695. declare module BABYLON {
  30696. /** @hidden */
  30697. class _FacetDataStorage {
  30698. facetPositions: Vector3[];
  30699. facetNormals: Vector3[];
  30700. facetPartitioning: number[][];
  30701. facetNb: number;
  30702. partitioningSubdivisions: number;
  30703. partitioningBBoxRatio: number;
  30704. facetDataEnabled: boolean;
  30705. facetParameters: any;
  30706. bbSize: Vector3;
  30707. subDiv: {
  30708. max: number;
  30709. X: number;
  30710. Y: number;
  30711. Z: number;
  30712. };
  30713. facetDepthSort: boolean;
  30714. facetDepthSortEnabled: boolean;
  30715. depthSortedIndices: IndicesArray;
  30716. depthSortedFacets: {
  30717. ind: number;
  30718. sqDistance: number;
  30719. }[];
  30720. facetDepthSortFunction: (f1: {
  30721. ind: number;
  30722. sqDistance: number;
  30723. }, f2: {
  30724. ind: number;
  30725. sqDistance: number;
  30726. }) => number;
  30727. facetDepthSortFrom: Vector3;
  30728. facetDepthSortOrigin: Vector3;
  30729. invertedMatrix: Matrix;
  30730. }
  30731. /**
  30732. * @hidden
  30733. **/
  30734. class _InternalAbstractMeshDataInfo {
  30735. _hasVertexAlpha: boolean;
  30736. _useVertexColors: boolean;
  30737. _numBoneInfluencers: number;
  30738. _applyFog: boolean;
  30739. _receiveShadows: boolean;
  30740. _facetData: _FacetDataStorage;
  30741. _visibility: number;
  30742. _skeleton: Nullable<Skeleton>;
  30743. _layerMask: number;
  30744. _computeBonesUsingShaders: boolean;
  30745. _isActive: boolean;
  30746. _onlyForInstances: boolean;
  30747. _isActiveIntermediate: boolean;
  30748. _onlyForInstancesIntermediate: boolean;
  30749. _actAsRegularMesh: boolean;
  30750. }
  30751. /**
  30752. * Class used to store all common mesh properties
  30753. */
  30754. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  30755. /** No occlusion */
  30756. static OCCLUSION_TYPE_NONE: number;
  30757. /** Occlusion set to optimisitic */
  30758. static OCCLUSION_TYPE_OPTIMISTIC: number;
  30759. /** Occlusion set to strict */
  30760. static OCCLUSION_TYPE_STRICT: number;
  30761. /** Use an accurante occlusion algorithm */
  30762. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  30763. /** Use a conservative occlusion algorithm */
  30764. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  30765. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  30766. * Test order :
  30767. * Is the bounding sphere outside the frustum ?
  30768. * If not, are the bounding box vertices outside the frustum ?
  30769. * It not, then the cullable object is in the frustum.
  30770. */
  30771. static readonly CULLINGSTRATEGY_STANDARD: number;
  30772. /** Culling strategy : Bounding Sphere Only.
  30773. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  30774. * It's also less accurate than the standard because some not visible objects can still be selected.
  30775. * Test : is the bounding sphere outside the frustum ?
  30776. * If not, then the cullable object is in the frustum.
  30777. */
  30778. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  30779. /** Culling strategy : Optimistic Inclusion.
  30780. * This in an inclusion test first, then the standard exclusion test.
  30781. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  30782. * 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.
  30783. * Anyway, it's as accurate as the standard strategy.
  30784. * Test :
  30785. * Is the cullable object bounding sphere center in the frustum ?
  30786. * If not, apply the default culling strategy.
  30787. */
  30788. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  30789. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  30790. * This in an inclusion test first, then the bounding sphere only exclusion test.
  30791. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  30792. * 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.
  30793. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  30794. * Test :
  30795. * Is the cullable object bounding sphere center in the frustum ?
  30796. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  30797. */
  30798. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  30799. /**
  30800. * No billboard
  30801. */
  30802. static get BILLBOARDMODE_NONE(): number;
  30803. /** Billboard on X axis */
  30804. static get BILLBOARDMODE_X(): number;
  30805. /** Billboard on Y axis */
  30806. static get BILLBOARDMODE_Y(): number;
  30807. /** Billboard on Z axis */
  30808. static get BILLBOARDMODE_Z(): number;
  30809. /** Billboard on all axes */
  30810. static get BILLBOARDMODE_ALL(): number;
  30811. /** Billboard on using position instead of orientation */
  30812. static get BILLBOARDMODE_USE_POSITION(): number;
  30813. /** @hidden */
  30814. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  30815. /**
  30816. * The culling strategy to use to check whether the mesh must be rendered or not.
  30817. * This value can be changed at any time and will be used on the next render mesh selection.
  30818. * The possible values are :
  30819. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  30820. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30821. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  30822. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  30823. * Please read each static variable documentation to get details about the culling process.
  30824. * */
  30825. cullingStrategy: number;
  30826. /**
  30827. * Gets the number of facets in the mesh
  30828. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  30829. */
  30830. get facetNb(): number;
  30831. /**
  30832. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  30833. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  30834. */
  30835. get partitioningSubdivisions(): number;
  30836. set partitioningSubdivisions(nb: number);
  30837. /**
  30838. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  30839. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  30840. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  30841. */
  30842. get partitioningBBoxRatio(): number;
  30843. set partitioningBBoxRatio(ratio: number);
  30844. /**
  30845. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  30846. * Works only for updatable meshes.
  30847. * Doesn't work with multi-materials
  30848. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  30849. */
  30850. get mustDepthSortFacets(): boolean;
  30851. set mustDepthSortFacets(sort: boolean);
  30852. /**
  30853. * The location (Vector3) where the facet depth sort must be computed from.
  30854. * By default, the active camera position.
  30855. * Used only when facet depth sort is enabled
  30856. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  30857. */
  30858. get facetDepthSortFrom(): Vector3;
  30859. set facetDepthSortFrom(location: Vector3);
  30860. /**
  30861. * gets a boolean indicating if facetData is enabled
  30862. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  30863. */
  30864. get isFacetDataEnabled(): boolean;
  30865. /** @hidden */
  30866. _updateNonUniformScalingState(value: boolean): boolean;
  30867. /**
  30868. * An event triggered when this mesh collides with another one
  30869. */
  30870. onCollideObservable: Observable<AbstractMesh>;
  30871. /** Set a function to call when this mesh collides with another one */
  30872. set onCollide(callback: () => void);
  30873. /**
  30874. * An event triggered when the collision's position changes
  30875. */
  30876. onCollisionPositionChangeObservable: Observable<Vector3>;
  30877. /** Set a function to call when the collision's position changes */
  30878. set onCollisionPositionChange(callback: () => void);
  30879. /**
  30880. * An event triggered when material is changed
  30881. */
  30882. onMaterialChangedObservable: Observable<AbstractMesh>;
  30883. /**
  30884. * Gets or sets the orientation for POV movement & rotation
  30885. */
  30886. definedFacingForward: boolean;
  30887. /** @hidden */
  30888. _occlusionQuery: Nullable<WebGLQuery>;
  30889. /** @hidden */
  30890. _renderingGroup: Nullable<RenderingGroup>;
  30891. /**
  30892. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  30893. */
  30894. get visibility(): number;
  30895. /**
  30896. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  30897. */
  30898. set visibility(value: number);
  30899. /** Gets or sets the alpha index used to sort transparent meshes
  30900. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  30901. */
  30902. alphaIndex: number;
  30903. /**
  30904. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  30905. */
  30906. isVisible: boolean;
  30907. /**
  30908. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  30909. */
  30910. isPickable: boolean;
  30911. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  30912. showSubMeshesBoundingBox: boolean;
  30913. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  30914. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  30915. */
  30916. isBlocker: boolean;
  30917. /**
  30918. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  30919. */
  30920. enablePointerMoveEvents: boolean;
  30921. /**
  30922. * Specifies the rendering group id for this mesh (0 by default)
  30923. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  30924. */
  30925. renderingGroupId: number;
  30926. private _material;
  30927. /** Gets or sets current material */
  30928. get material(): Nullable<Material>;
  30929. set material(value: Nullable<Material>);
  30930. /**
  30931. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  30932. * @see http://doc.babylonjs.com/babylon101/shadows
  30933. */
  30934. get receiveShadows(): boolean;
  30935. set receiveShadows(value: boolean);
  30936. /** Defines color to use when rendering outline */
  30937. outlineColor: Color3;
  30938. /** Define width to use when rendering outline */
  30939. outlineWidth: number;
  30940. /** Defines color to use when rendering overlay */
  30941. overlayColor: Color3;
  30942. /** Defines alpha to use when rendering overlay */
  30943. overlayAlpha: number;
  30944. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  30945. get hasVertexAlpha(): boolean;
  30946. set hasVertexAlpha(value: boolean);
  30947. /** 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) */
  30948. get useVertexColors(): boolean;
  30949. set useVertexColors(value: boolean);
  30950. /**
  30951. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  30952. */
  30953. get computeBonesUsingShaders(): boolean;
  30954. set computeBonesUsingShaders(value: boolean);
  30955. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  30956. get numBoneInfluencers(): number;
  30957. set numBoneInfluencers(value: number);
  30958. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  30959. get applyFog(): boolean;
  30960. set applyFog(value: boolean);
  30961. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  30962. useOctreeForRenderingSelection: boolean;
  30963. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  30964. useOctreeForPicking: boolean;
  30965. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  30966. useOctreeForCollisions: boolean;
  30967. /**
  30968. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  30969. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  30970. */
  30971. get layerMask(): number;
  30972. set layerMask(value: number);
  30973. /**
  30974. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  30975. */
  30976. alwaysSelectAsActiveMesh: boolean;
  30977. /**
  30978. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  30979. */
  30980. doNotSyncBoundingInfo: boolean;
  30981. /**
  30982. * Gets or sets the current action manager
  30983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  30984. */
  30985. actionManager: Nullable<AbstractActionManager>;
  30986. private _meshCollisionData;
  30987. /**
  30988. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  30989. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  30990. */
  30991. ellipsoid: Vector3;
  30992. /**
  30993. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  30994. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  30995. */
  30996. ellipsoidOffset: Vector3;
  30997. /**
  30998. * Gets or sets a collision mask used to mask collisions (default is -1).
  30999. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31000. */
  31001. get collisionMask(): number;
  31002. set collisionMask(mask: number);
  31003. /**
  31004. * Gets or sets the current collision group mask (-1 by default).
  31005. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31006. */
  31007. get collisionGroup(): number;
  31008. set collisionGroup(mask: number);
  31009. /**
  31010. * Gets or sets current surrounding meshes (null by default).
  31011. *
  31012. * By default collision detection is tested against every mesh in the scene.
  31013. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  31014. * meshes will be tested for the collision.
  31015. *
  31016. * Note: if set to an empty array no collision will happen when this mesh is moved.
  31017. */
  31018. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  31019. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  31020. /**
  31021. * Defines edge width used when edgesRenderer is enabled
  31022. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31023. */
  31024. edgesWidth: number;
  31025. /**
  31026. * Defines edge color used when edgesRenderer is enabled
  31027. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31028. */
  31029. edgesColor: Color4;
  31030. /** @hidden */
  31031. _edgesRenderer: Nullable<IEdgesRenderer>;
  31032. /** @hidden */
  31033. _masterMesh: Nullable<AbstractMesh>;
  31034. /** @hidden */
  31035. _boundingInfo: Nullable<BoundingInfo>;
  31036. /** @hidden */
  31037. _renderId: number;
  31038. /**
  31039. * Gets or sets the list of subMeshes
  31040. * @see http://doc.babylonjs.com/how_to/multi_materials
  31041. */
  31042. subMeshes: SubMesh[];
  31043. /** @hidden */
  31044. _intersectionsInProgress: AbstractMesh[];
  31045. /** @hidden */
  31046. _unIndexed: boolean;
  31047. /** @hidden */
  31048. _lightSources: Light[];
  31049. /** Gets the list of lights affecting that mesh */
  31050. get lightSources(): Light[];
  31051. /** @hidden */
  31052. get _positions(): Nullable<Vector3[]>;
  31053. /** @hidden */
  31054. _waitingData: {
  31055. lods: Nullable<any>;
  31056. actions: Nullable<any>;
  31057. freezeWorldMatrix: Nullable<boolean>;
  31058. };
  31059. /** @hidden */
  31060. _bonesTransformMatrices: Nullable<Float32Array>;
  31061. /** @hidden */
  31062. _transformMatrixTexture: Nullable<RawTexture>;
  31063. /**
  31064. * Gets or sets a skeleton to apply skining transformations
  31065. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  31066. */
  31067. set skeleton(value: Nullable<Skeleton>);
  31068. get skeleton(): Nullable<Skeleton>;
  31069. /**
  31070. * An event triggered when the mesh is rebuilt.
  31071. */
  31072. onRebuildObservable: Observable<AbstractMesh>;
  31073. /**
  31074. * Creates a new AbstractMesh
  31075. * @param name defines the name of the mesh
  31076. * @param scene defines the hosting scene
  31077. */
  31078. constructor(name: string, scene?: Nullable<Scene>);
  31079. /**
  31080. * Returns the string "AbstractMesh"
  31081. * @returns "AbstractMesh"
  31082. */
  31083. getClassName(): string;
  31084. /**
  31085. * Gets a string representation of the current mesh
  31086. * @param fullDetails defines a boolean indicating if full details must be included
  31087. * @returns a string representation of the current mesh
  31088. */
  31089. toString(fullDetails?: boolean): string;
  31090. /**
  31091. * @hidden
  31092. */
  31093. protected _getEffectiveParent(): Nullable<Node>;
  31094. /** @hidden */
  31095. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  31096. /** @hidden */
  31097. _rebuild(): void;
  31098. /** @hidden */
  31099. _resyncLightSources(): void;
  31100. /** @hidden */
  31101. _resyncLightSource(light: Light): void;
  31102. /** @hidden */
  31103. _unBindEffect(): void;
  31104. /** @hidden */
  31105. _removeLightSource(light: Light, dispose: boolean): void;
  31106. private _markSubMeshesAsDirty;
  31107. /** @hidden */
  31108. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  31109. /** @hidden */
  31110. _markSubMeshesAsAttributesDirty(): void;
  31111. /** @hidden */
  31112. _markSubMeshesAsMiscDirty(): void;
  31113. /**
  31114. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  31115. */
  31116. get scaling(): Vector3;
  31117. set scaling(newScaling: Vector3);
  31118. /**
  31119. * Returns true if the mesh is blocked. Implemented by child classes
  31120. */
  31121. get isBlocked(): boolean;
  31122. /**
  31123. * Returns the mesh itself by default. Implemented by child classes
  31124. * @param camera defines the camera to use to pick the right LOD level
  31125. * @returns the currentAbstractMesh
  31126. */
  31127. getLOD(camera: Camera): Nullable<AbstractMesh>;
  31128. /**
  31129. * Returns 0 by default. Implemented by child classes
  31130. * @returns an integer
  31131. */
  31132. getTotalVertices(): number;
  31133. /**
  31134. * Returns a positive integer : the total number of indices in this mesh geometry.
  31135. * @returns the numner of indices or zero if the mesh has no geometry.
  31136. */
  31137. getTotalIndices(): number;
  31138. /**
  31139. * Returns null by default. Implemented by child classes
  31140. * @returns null
  31141. */
  31142. getIndices(): Nullable<IndicesArray>;
  31143. /**
  31144. * Returns the array of the requested vertex data kind. Implemented by child classes
  31145. * @param kind defines the vertex data kind to use
  31146. * @returns null
  31147. */
  31148. getVerticesData(kind: string): Nullable<FloatArray>;
  31149. /**
  31150. * Sets the vertex data of the mesh geometry for the requested `kind`.
  31151. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  31152. * Note that a new underlying VertexBuffer object is created each call.
  31153. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  31154. * @param kind defines vertex data kind:
  31155. * * VertexBuffer.PositionKind
  31156. * * VertexBuffer.UVKind
  31157. * * VertexBuffer.UV2Kind
  31158. * * VertexBuffer.UV3Kind
  31159. * * VertexBuffer.UV4Kind
  31160. * * VertexBuffer.UV5Kind
  31161. * * VertexBuffer.UV6Kind
  31162. * * VertexBuffer.ColorKind
  31163. * * VertexBuffer.MatricesIndicesKind
  31164. * * VertexBuffer.MatricesIndicesExtraKind
  31165. * * VertexBuffer.MatricesWeightsKind
  31166. * * VertexBuffer.MatricesWeightsExtraKind
  31167. * @param data defines the data source
  31168. * @param updatable defines if the data must be flagged as updatable (or static)
  31169. * @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
  31170. * @returns the current mesh
  31171. */
  31172. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  31173. /**
  31174. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  31175. * If the mesh has no geometry, it is simply returned as it is.
  31176. * @param kind defines vertex data kind:
  31177. * * VertexBuffer.PositionKind
  31178. * * VertexBuffer.UVKind
  31179. * * VertexBuffer.UV2Kind
  31180. * * VertexBuffer.UV3Kind
  31181. * * VertexBuffer.UV4Kind
  31182. * * VertexBuffer.UV5Kind
  31183. * * VertexBuffer.UV6Kind
  31184. * * VertexBuffer.ColorKind
  31185. * * VertexBuffer.MatricesIndicesKind
  31186. * * VertexBuffer.MatricesIndicesExtraKind
  31187. * * VertexBuffer.MatricesWeightsKind
  31188. * * VertexBuffer.MatricesWeightsExtraKind
  31189. * @param data defines the data source
  31190. * @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
  31191. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  31192. * @returns the current mesh
  31193. */
  31194. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  31195. /**
  31196. * Sets the mesh indices,
  31197. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  31198. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  31199. * @param totalVertices Defines the total number of vertices
  31200. * @returns the current mesh
  31201. */
  31202. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  31203. /**
  31204. * Gets a boolean indicating if specific vertex data is present
  31205. * @param kind defines the vertex data kind to use
  31206. * @returns true is data kind is present
  31207. */
  31208. isVerticesDataPresent(kind: string): boolean;
  31209. /**
  31210. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  31211. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  31212. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  31213. * @returns a BoundingInfo
  31214. */
  31215. getBoundingInfo(): BoundingInfo;
  31216. /**
  31217. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  31218. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  31219. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  31220. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  31221. * @returns the current mesh
  31222. */
  31223. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  31224. /**
  31225. * Overwrite the current bounding info
  31226. * @param boundingInfo defines the new bounding info
  31227. * @returns the current mesh
  31228. */
  31229. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  31230. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  31231. get useBones(): boolean;
  31232. /** @hidden */
  31233. _preActivate(): void;
  31234. /** @hidden */
  31235. _preActivateForIntermediateRendering(renderId: number): void;
  31236. /** @hidden */
  31237. _activate(renderId: number, intermediateRendering: boolean): boolean;
  31238. /** @hidden */
  31239. _postActivate(): void;
  31240. /** @hidden */
  31241. _freeze(): void;
  31242. /** @hidden */
  31243. _unFreeze(): void;
  31244. /**
  31245. * Gets the current world matrix
  31246. * @returns a Matrix
  31247. */
  31248. getWorldMatrix(): Matrix;
  31249. /** @hidden */
  31250. _getWorldMatrixDeterminant(): number;
  31251. /**
  31252. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  31253. */
  31254. get isAnInstance(): boolean;
  31255. /**
  31256. * Gets a boolean indicating if this mesh has instances
  31257. */
  31258. get hasInstances(): boolean;
  31259. /**
  31260. * Perform relative position change from the point of view of behind the front of the mesh.
  31261. * This is performed taking into account the meshes current rotation, so you do not have to care.
  31262. * Supports definition of mesh facing forward or backward
  31263. * @param amountRight defines the distance on the right axis
  31264. * @param amountUp defines the distance on the up axis
  31265. * @param amountForward defines the distance on the forward axis
  31266. * @returns the current mesh
  31267. */
  31268. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  31269. /**
  31270. * Calculate relative position change from the point of view of behind the front of the mesh.
  31271. * This is performed taking into account the meshes current rotation, so you do not have to care.
  31272. * Supports definition of mesh facing forward or backward
  31273. * @param amountRight defines the distance on the right axis
  31274. * @param amountUp defines the distance on the up axis
  31275. * @param amountForward defines the distance on the forward axis
  31276. * @returns the new displacement vector
  31277. */
  31278. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  31279. /**
  31280. * Perform relative rotation change from the point of view of behind the front of the mesh.
  31281. * Supports definition of mesh facing forward or backward
  31282. * @param flipBack defines the flip
  31283. * @param twirlClockwise defines the twirl
  31284. * @param tiltRight defines the tilt
  31285. * @returns the current mesh
  31286. */
  31287. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  31288. /**
  31289. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  31290. * Supports definition of mesh facing forward or backward.
  31291. * @param flipBack defines the flip
  31292. * @param twirlClockwise defines the twirl
  31293. * @param tiltRight defines the tilt
  31294. * @returns the new rotation vector
  31295. */
  31296. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  31297. /**
  31298. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  31299. * This means the mesh underlying bounding box and sphere are recomputed.
  31300. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  31301. * @returns the current mesh
  31302. */
  31303. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  31304. /** @hidden */
  31305. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  31306. /** @hidden */
  31307. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  31308. /** @hidden */
  31309. _updateBoundingInfo(): AbstractMesh;
  31310. /** @hidden */
  31311. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  31312. /** @hidden */
  31313. protected _afterComputeWorldMatrix(): void;
  31314. /** @hidden */
  31315. get _effectiveMesh(): AbstractMesh;
  31316. /**
  31317. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  31318. * A mesh is in the frustum if its bounding box intersects the frustum
  31319. * @param frustumPlanes defines the frustum to test
  31320. * @returns true if the mesh is in the frustum planes
  31321. */
  31322. isInFrustum(frustumPlanes: Plane[]): boolean;
  31323. /**
  31324. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  31325. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  31326. * @param frustumPlanes defines the frustum to test
  31327. * @returns true if the mesh is completely in the frustum planes
  31328. */
  31329. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  31330. /**
  31331. * True if the mesh intersects another mesh or a SolidParticle object
  31332. * @param mesh defines a target mesh or SolidParticle to test
  31333. * @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)
  31334. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  31335. * @returns true if there is an intersection
  31336. */
  31337. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  31338. /**
  31339. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  31340. * @param point defines the point to test
  31341. * @returns true if there is an intersection
  31342. */
  31343. intersectsPoint(point: Vector3): boolean;
  31344. /**
  31345. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  31346. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31347. */
  31348. get checkCollisions(): boolean;
  31349. set checkCollisions(collisionEnabled: boolean);
  31350. /**
  31351. * Gets Collider object used to compute collisions (not physics)
  31352. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31353. */
  31354. get collider(): Nullable<Collider>;
  31355. /**
  31356. * Move the mesh using collision engine
  31357. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31358. * @param displacement defines the requested displacement vector
  31359. * @returns the current mesh
  31360. */
  31361. moveWithCollisions(displacement: Vector3): AbstractMesh;
  31362. private _onCollisionPositionChange;
  31363. /** @hidden */
  31364. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  31365. /** @hidden */
  31366. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  31367. /** @hidden */
  31368. _checkCollision(collider: Collider): AbstractMesh;
  31369. /** @hidden */
  31370. _generatePointsArray(): boolean;
  31371. /**
  31372. * Checks if the passed Ray intersects with the mesh
  31373. * @param ray defines the ray to use
  31374. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  31375. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31376. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  31377. * @returns the picking info
  31378. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  31379. */
  31380. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  31381. /**
  31382. * Clones the current mesh
  31383. * @param name defines the mesh name
  31384. * @param newParent defines the new mesh parent
  31385. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  31386. * @returns the new mesh
  31387. */
  31388. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  31389. /**
  31390. * Disposes all the submeshes of the current meshnp
  31391. * @returns the current mesh
  31392. */
  31393. releaseSubMeshes(): AbstractMesh;
  31394. /**
  31395. * Releases resources associated with this abstract mesh.
  31396. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31397. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31398. */
  31399. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31400. /**
  31401. * Adds the passed mesh as a child to the current mesh
  31402. * @param mesh defines the child mesh
  31403. * @returns the current mesh
  31404. */
  31405. addChild(mesh: AbstractMesh): AbstractMesh;
  31406. /**
  31407. * Removes the passed mesh from the current mesh children list
  31408. * @param mesh defines the child mesh
  31409. * @returns the current mesh
  31410. */
  31411. removeChild(mesh: AbstractMesh): AbstractMesh;
  31412. /** @hidden */
  31413. private _initFacetData;
  31414. /**
  31415. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  31416. * This method can be called within the render loop.
  31417. * 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
  31418. * @returns the current mesh
  31419. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31420. */
  31421. updateFacetData(): AbstractMesh;
  31422. /**
  31423. * Returns the facetLocalNormals array.
  31424. * The normals are expressed in the mesh local spac
  31425. * @returns an array of Vector3
  31426. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31427. */
  31428. getFacetLocalNormals(): Vector3[];
  31429. /**
  31430. * Returns the facetLocalPositions array.
  31431. * The facet positions are expressed in the mesh local space
  31432. * @returns an array of Vector3
  31433. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31434. */
  31435. getFacetLocalPositions(): Vector3[];
  31436. /**
  31437. * Returns the facetLocalPartioning array
  31438. * @returns an array of array of numbers
  31439. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31440. */
  31441. getFacetLocalPartitioning(): number[][];
  31442. /**
  31443. * Returns the i-th facet position in the world system.
  31444. * This method allocates a new Vector3 per call
  31445. * @param i defines the facet index
  31446. * @returns a new Vector3
  31447. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31448. */
  31449. getFacetPosition(i: number): Vector3;
  31450. /**
  31451. * Sets the reference Vector3 with the i-th facet position in the world system
  31452. * @param i defines the facet index
  31453. * @param ref defines the target vector
  31454. * @returns the current mesh
  31455. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31456. */
  31457. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  31458. /**
  31459. * Returns the i-th facet normal in the world system.
  31460. * This method allocates a new Vector3 per call
  31461. * @param i defines the facet index
  31462. * @returns a new Vector3
  31463. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31464. */
  31465. getFacetNormal(i: number): Vector3;
  31466. /**
  31467. * Sets the reference Vector3 with the i-th facet normal in the world system
  31468. * @param i defines the facet index
  31469. * @param ref defines the target vector
  31470. * @returns the current mesh
  31471. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31472. */
  31473. getFacetNormalToRef(i: number, ref: Vector3): this;
  31474. /**
  31475. * 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)
  31476. * @param x defines x coordinate
  31477. * @param y defines y coordinate
  31478. * @param z defines z coordinate
  31479. * @returns the array of facet indexes
  31480. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31481. */
  31482. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  31483. /**
  31484. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  31485. * @param projected sets as the (x,y,z) world projection on the facet
  31486. * @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
  31487. * @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
  31488. * @param x defines x coordinate
  31489. * @param y defines y coordinate
  31490. * @param z defines z coordinate
  31491. * @returns the face index if found (or null instead)
  31492. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31493. */
  31494. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  31495. /**
  31496. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  31497. * @param projected sets as the (x,y,z) local projection on the facet
  31498. * @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
  31499. * @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
  31500. * @param x defines x coordinate
  31501. * @param y defines y coordinate
  31502. * @param z defines z coordinate
  31503. * @returns the face index if found (or null instead)
  31504. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31505. */
  31506. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  31507. /**
  31508. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  31509. * @returns the parameters
  31510. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31511. */
  31512. getFacetDataParameters(): any;
  31513. /**
  31514. * Disables the feature FacetData and frees the related memory
  31515. * @returns the current mesh
  31516. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31517. */
  31518. disableFacetData(): AbstractMesh;
  31519. /**
  31520. * Updates the AbstractMesh indices array
  31521. * @param indices defines the data source
  31522. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  31523. * @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)
  31524. * @returns the current mesh
  31525. */
  31526. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  31527. /**
  31528. * Creates new normals data for the mesh
  31529. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  31530. * @returns the current mesh
  31531. */
  31532. createNormals(updatable: boolean): AbstractMesh;
  31533. /**
  31534. * Align the mesh with a normal
  31535. * @param normal defines the normal to use
  31536. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  31537. * @returns the current mesh
  31538. */
  31539. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  31540. /** @hidden */
  31541. _checkOcclusionQuery(): boolean;
  31542. /**
  31543. * Disables the mesh edge rendering mode
  31544. * @returns the currentAbstractMesh
  31545. */
  31546. disableEdgesRendering(): AbstractMesh;
  31547. /**
  31548. * Enables the edge rendering mode on the mesh.
  31549. * This mode makes the mesh edges visible
  31550. * @param epsilon defines the maximal distance between two angles to detect a face
  31551. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  31552. * @returns the currentAbstractMesh
  31553. * @see https://www.babylonjs-playground.com/#19O9TU#0
  31554. */
  31555. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  31556. }
  31557. }
  31558. declare module BABYLON {
  31559. /**
  31560. * Interface used to define ActionEvent
  31561. */
  31562. export interface IActionEvent {
  31563. /** The mesh or sprite that triggered the action */
  31564. source: any;
  31565. /** The X mouse cursor position at the time of the event */
  31566. pointerX: number;
  31567. /** The Y mouse cursor position at the time of the event */
  31568. pointerY: number;
  31569. /** The mesh that is currently pointed at (can be null) */
  31570. meshUnderPointer: Nullable<AbstractMesh>;
  31571. /** the original (browser) event that triggered the ActionEvent */
  31572. sourceEvent?: any;
  31573. /** additional data for the event */
  31574. additionalData?: any;
  31575. }
  31576. /**
  31577. * ActionEvent is the event being sent when an action is triggered.
  31578. */
  31579. export class ActionEvent implements IActionEvent {
  31580. /** The mesh or sprite that triggered the action */
  31581. source: any;
  31582. /** The X mouse cursor position at the time of the event */
  31583. pointerX: number;
  31584. /** The Y mouse cursor position at the time of the event */
  31585. pointerY: number;
  31586. /** The mesh that is currently pointed at (can be null) */
  31587. meshUnderPointer: Nullable<AbstractMesh>;
  31588. /** the original (browser) event that triggered the ActionEvent */
  31589. sourceEvent?: any;
  31590. /** additional data for the event */
  31591. additionalData?: any;
  31592. /**
  31593. * Creates a new ActionEvent
  31594. * @param source The mesh or sprite that triggered the action
  31595. * @param pointerX The X mouse cursor position at the time of the event
  31596. * @param pointerY The Y mouse cursor position at the time of the event
  31597. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  31598. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  31599. * @param additionalData additional data for the event
  31600. */
  31601. constructor(
  31602. /** The mesh or sprite that triggered the action */
  31603. source: any,
  31604. /** The X mouse cursor position at the time of the event */
  31605. pointerX: number,
  31606. /** The Y mouse cursor position at the time of the event */
  31607. pointerY: number,
  31608. /** The mesh that is currently pointed at (can be null) */
  31609. meshUnderPointer: Nullable<AbstractMesh>,
  31610. /** the original (browser) event that triggered the ActionEvent */
  31611. sourceEvent?: any,
  31612. /** additional data for the event */
  31613. additionalData?: any);
  31614. /**
  31615. * Helper function to auto-create an ActionEvent from a source mesh.
  31616. * @param source The source mesh that triggered the event
  31617. * @param evt The original (browser) event
  31618. * @param additionalData additional data for the event
  31619. * @returns the new ActionEvent
  31620. */
  31621. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  31622. /**
  31623. * Helper function to auto-create an ActionEvent from a source sprite
  31624. * @param source The source sprite that triggered the event
  31625. * @param scene Scene associated with the sprite
  31626. * @param evt The original (browser) event
  31627. * @param additionalData additional data for the event
  31628. * @returns the new ActionEvent
  31629. */
  31630. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  31631. /**
  31632. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  31633. * @param scene the scene where the event occurred
  31634. * @param evt The original (browser) event
  31635. * @returns the new ActionEvent
  31636. */
  31637. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  31638. /**
  31639. * Helper function to auto-create an ActionEvent from a primitive
  31640. * @param prim defines the target primitive
  31641. * @param pointerPos defines the pointer position
  31642. * @param evt The original (browser) event
  31643. * @param additionalData additional data for the event
  31644. * @returns the new ActionEvent
  31645. */
  31646. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  31647. }
  31648. }
  31649. declare module BABYLON {
  31650. /**
  31651. * Abstract class used to decouple action Manager from scene and meshes.
  31652. * Do not instantiate.
  31653. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31654. */
  31655. export abstract class AbstractActionManager implements IDisposable {
  31656. /** Gets the list of active triggers */
  31657. static Triggers: {
  31658. [key: string]: number;
  31659. };
  31660. /** Gets the cursor to use when hovering items */
  31661. hoverCursor: string;
  31662. /** Gets the list of actions */
  31663. actions: IAction[];
  31664. /**
  31665. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  31666. */
  31667. isRecursive: boolean;
  31668. /**
  31669. * Releases all associated resources
  31670. */
  31671. abstract dispose(): void;
  31672. /**
  31673. * Does this action manager has pointer triggers
  31674. */
  31675. abstract get hasPointerTriggers(): boolean;
  31676. /**
  31677. * Does this action manager has pick triggers
  31678. */
  31679. abstract get hasPickTriggers(): boolean;
  31680. /**
  31681. * Process a specific trigger
  31682. * @param trigger defines the trigger to process
  31683. * @param evt defines the event details to be processed
  31684. */
  31685. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  31686. /**
  31687. * Does this action manager handles actions of any of the given triggers
  31688. * @param triggers defines the triggers to be tested
  31689. * @return a boolean indicating whether one (or more) of the triggers is handled
  31690. */
  31691. abstract hasSpecificTriggers(triggers: number[]): boolean;
  31692. /**
  31693. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  31694. * speed.
  31695. * @param triggerA defines the trigger to be tested
  31696. * @param triggerB defines the trigger to be tested
  31697. * @return a boolean indicating whether one (or more) of the triggers is handled
  31698. */
  31699. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  31700. /**
  31701. * Does this action manager handles actions of a given trigger
  31702. * @param trigger defines the trigger to be tested
  31703. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  31704. * @return whether the trigger is handled
  31705. */
  31706. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  31707. /**
  31708. * Serialize this manager to a JSON object
  31709. * @param name defines the property name to store this manager
  31710. * @returns a JSON representation of this manager
  31711. */
  31712. abstract serialize(name: string): any;
  31713. /**
  31714. * Registers an action to this action manager
  31715. * @param action defines the action to be registered
  31716. * @return the action amended (prepared) after registration
  31717. */
  31718. abstract registerAction(action: IAction): Nullable<IAction>;
  31719. /**
  31720. * Unregisters an action to this action manager
  31721. * @param action defines the action to be unregistered
  31722. * @return a boolean indicating whether the action has been unregistered
  31723. */
  31724. abstract unregisterAction(action: IAction): Boolean;
  31725. /**
  31726. * Does exist one action manager with at least one trigger
  31727. **/
  31728. static get HasTriggers(): boolean;
  31729. /**
  31730. * Does exist one action manager with at least one pick trigger
  31731. **/
  31732. static get HasPickTriggers(): boolean;
  31733. /**
  31734. * Does exist one action manager that handles actions of a given trigger
  31735. * @param trigger defines the trigger to be tested
  31736. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  31737. **/
  31738. static HasSpecificTrigger(trigger: number): boolean;
  31739. }
  31740. }
  31741. declare module BABYLON {
  31742. /**
  31743. * Defines how a node can be built from a string name.
  31744. */
  31745. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  31746. /**
  31747. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  31748. */
  31749. export class Node implements IBehaviorAware<Node> {
  31750. /** @hidden */
  31751. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  31752. private static _NodeConstructors;
  31753. /**
  31754. * Add a new node constructor
  31755. * @param type defines the type name of the node to construct
  31756. * @param constructorFunc defines the constructor function
  31757. */
  31758. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  31759. /**
  31760. * Returns a node constructor based on type name
  31761. * @param type defines the type name
  31762. * @param name defines the new node name
  31763. * @param scene defines the hosting scene
  31764. * @param options defines optional options to transmit to constructors
  31765. * @returns the new constructor or null
  31766. */
  31767. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  31768. /**
  31769. * Gets or sets the name of the node
  31770. */
  31771. name: string;
  31772. /**
  31773. * Gets or sets the id of the node
  31774. */
  31775. id: string;
  31776. /**
  31777. * Gets or sets the unique id of the node
  31778. */
  31779. uniqueId: number;
  31780. /**
  31781. * Gets or sets a string used to store user defined state for the node
  31782. */
  31783. state: string;
  31784. /**
  31785. * Gets or sets an object used to store user defined information for the node
  31786. */
  31787. metadata: any;
  31788. /**
  31789. * For internal use only. Please do not use.
  31790. */
  31791. reservedDataStore: any;
  31792. /**
  31793. * List of inspectable custom properties (used by the Inspector)
  31794. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  31795. */
  31796. inspectableCustomProperties: IInspectable[];
  31797. private _doNotSerialize;
  31798. /**
  31799. * Gets or sets a boolean used to define if the node must be serialized
  31800. */
  31801. get doNotSerialize(): boolean;
  31802. set doNotSerialize(value: boolean);
  31803. /** @hidden */
  31804. _isDisposed: boolean;
  31805. /**
  31806. * Gets a list of Animations associated with the node
  31807. */
  31808. animations: Animation[];
  31809. protected _ranges: {
  31810. [name: string]: Nullable<AnimationRange>;
  31811. };
  31812. /**
  31813. * Callback raised when the node is ready to be used
  31814. */
  31815. onReady: Nullable<(node: Node) => void>;
  31816. private _isEnabled;
  31817. private _isParentEnabled;
  31818. private _isReady;
  31819. /** @hidden */
  31820. _currentRenderId: number;
  31821. private _parentUpdateId;
  31822. /** @hidden */
  31823. _childUpdateId: number;
  31824. /** @hidden */
  31825. _waitingParentId: Nullable<string>;
  31826. /** @hidden */
  31827. _scene: Scene;
  31828. /** @hidden */
  31829. _cache: any;
  31830. private _parentNode;
  31831. private _children;
  31832. /** @hidden */
  31833. _worldMatrix: Matrix;
  31834. /** @hidden */
  31835. _worldMatrixDeterminant: number;
  31836. /** @hidden */
  31837. _worldMatrixDeterminantIsDirty: boolean;
  31838. /** @hidden */
  31839. private _sceneRootNodesIndex;
  31840. /**
  31841. * Gets a boolean indicating if the node has been disposed
  31842. * @returns true if the node was disposed
  31843. */
  31844. isDisposed(): boolean;
  31845. /**
  31846. * Gets or sets the parent of the node (without keeping the current position in the scene)
  31847. * @see https://doc.babylonjs.com/how_to/parenting
  31848. */
  31849. set parent(parent: Nullable<Node>);
  31850. get parent(): Nullable<Node>;
  31851. /** @hidden */
  31852. _addToSceneRootNodes(): void;
  31853. /** @hidden */
  31854. _removeFromSceneRootNodes(): void;
  31855. private _animationPropertiesOverride;
  31856. /**
  31857. * Gets or sets the animation properties override
  31858. */
  31859. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  31860. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  31861. /**
  31862. * Gets a string idenfifying the name of the class
  31863. * @returns "Node" string
  31864. */
  31865. getClassName(): string;
  31866. /** @hidden */
  31867. readonly _isNode: boolean;
  31868. /**
  31869. * An event triggered when the mesh is disposed
  31870. */
  31871. onDisposeObservable: Observable<Node>;
  31872. private _onDisposeObserver;
  31873. /**
  31874. * Sets a callback that will be raised when the node will be disposed
  31875. */
  31876. set onDispose(callback: () => void);
  31877. /**
  31878. * Creates a new Node
  31879. * @param name the name and id to be given to this node
  31880. * @param scene the scene this node will be added to
  31881. */
  31882. constructor(name: string, scene?: Nullable<Scene>);
  31883. /**
  31884. * Gets the scene of the node
  31885. * @returns a scene
  31886. */
  31887. getScene(): Scene;
  31888. /**
  31889. * Gets the engine of the node
  31890. * @returns a Engine
  31891. */
  31892. getEngine(): Engine;
  31893. private _behaviors;
  31894. /**
  31895. * Attach a behavior to the node
  31896. * @see http://doc.babylonjs.com/features/behaviour
  31897. * @param behavior defines the behavior to attach
  31898. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  31899. * @returns the current Node
  31900. */
  31901. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  31902. /**
  31903. * Remove an attached behavior
  31904. * @see http://doc.babylonjs.com/features/behaviour
  31905. * @param behavior defines the behavior to attach
  31906. * @returns the current Node
  31907. */
  31908. removeBehavior(behavior: Behavior<Node>): Node;
  31909. /**
  31910. * Gets the list of attached behaviors
  31911. * @see http://doc.babylonjs.com/features/behaviour
  31912. */
  31913. get behaviors(): Behavior<Node>[];
  31914. /**
  31915. * Gets an attached behavior by name
  31916. * @param name defines the name of the behavior to look for
  31917. * @see http://doc.babylonjs.com/features/behaviour
  31918. * @returns null if behavior was not found else the requested behavior
  31919. */
  31920. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  31921. /**
  31922. * Returns the latest update of the World matrix
  31923. * @returns a Matrix
  31924. */
  31925. getWorldMatrix(): Matrix;
  31926. /** @hidden */
  31927. _getWorldMatrixDeterminant(): number;
  31928. /**
  31929. * Returns directly the latest state of the mesh World matrix.
  31930. * A Matrix is returned.
  31931. */
  31932. get worldMatrixFromCache(): Matrix;
  31933. /** @hidden */
  31934. _initCache(): void;
  31935. /** @hidden */
  31936. updateCache(force?: boolean): void;
  31937. /** @hidden */
  31938. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  31939. /** @hidden */
  31940. _updateCache(ignoreParentClass?: boolean): void;
  31941. /** @hidden */
  31942. _isSynchronized(): boolean;
  31943. /** @hidden */
  31944. _markSyncedWithParent(): void;
  31945. /** @hidden */
  31946. isSynchronizedWithParent(): boolean;
  31947. /** @hidden */
  31948. isSynchronized(): boolean;
  31949. /**
  31950. * Is this node ready to be used/rendered
  31951. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  31952. * @return true if the node is ready
  31953. */
  31954. isReady(completeCheck?: boolean): boolean;
  31955. /**
  31956. * Is this node enabled?
  31957. * 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
  31958. * @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
  31959. * @return whether this node (and its parent) is enabled
  31960. */
  31961. isEnabled(checkAncestors?: boolean): boolean;
  31962. /** @hidden */
  31963. protected _syncParentEnabledState(): void;
  31964. /**
  31965. * Set the enabled state of this node
  31966. * @param value defines the new enabled state
  31967. */
  31968. setEnabled(value: boolean): void;
  31969. /**
  31970. * Is this node a descendant of the given node?
  31971. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  31972. * @param ancestor defines the parent node to inspect
  31973. * @returns a boolean indicating if this node is a descendant of the given node
  31974. */
  31975. isDescendantOf(ancestor: Node): boolean;
  31976. /** @hidden */
  31977. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  31978. /**
  31979. * Will return all nodes that have this node as ascendant
  31980. * @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
  31981. * @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
  31982. * @return all children nodes of all types
  31983. */
  31984. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  31985. /**
  31986. * Get all child-meshes of this node
  31987. * @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)
  31988. * @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
  31989. * @returns an array of AbstractMesh
  31990. */
  31991. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  31992. /**
  31993. * Get all direct children of this node
  31994. * @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
  31995. * @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)
  31996. * @returns an array of Node
  31997. */
  31998. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  31999. /** @hidden */
  32000. _setReady(state: boolean): void;
  32001. /**
  32002. * Get an animation by name
  32003. * @param name defines the name of the animation to look for
  32004. * @returns null if not found else the requested animation
  32005. */
  32006. getAnimationByName(name: string): Nullable<Animation>;
  32007. /**
  32008. * Creates an animation range for this node
  32009. * @param name defines the name of the range
  32010. * @param from defines the starting key
  32011. * @param to defines the end key
  32012. */
  32013. createAnimationRange(name: string, from: number, to: number): void;
  32014. /**
  32015. * Delete a specific animation range
  32016. * @param name defines the name of the range to delete
  32017. * @param deleteFrames defines if animation frames from the range must be deleted as well
  32018. */
  32019. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  32020. /**
  32021. * Get an animation range by name
  32022. * @param name defines the name of the animation range to look for
  32023. * @returns null if not found else the requested animation range
  32024. */
  32025. getAnimationRange(name: string): Nullable<AnimationRange>;
  32026. /**
  32027. * Gets the list of all animation ranges defined on this node
  32028. * @returns an array
  32029. */
  32030. getAnimationRanges(): Nullable<AnimationRange>[];
  32031. /**
  32032. * Will start the animation sequence
  32033. * @param name defines the range frames for animation sequence
  32034. * @param loop defines if the animation should loop (false by default)
  32035. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  32036. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  32037. * @returns the object created for this animation. If range does not exist, it will return null
  32038. */
  32039. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  32040. /**
  32041. * Serialize animation ranges into a JSON compatible object
  32042. * @returns serialization object
  32043. */
  32044. serializeAnimationRanges(): any;
  32045. /**
  32046. * Computes the world matrix of the node
  32047. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  32048. * @returns the world matrix
  32049. */
  32050. computeWorldMatrix(force?: boolean): Matrix;
  32051. /**
  32052. * Releases resources associated with this node.
  32053. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32054. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32055. */
  32056. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32057. /**
  32058. * Parse animation range data from a serialization object and store them into a given node
  32059. * @param node defines where to store the animation ranges
  32060. * @param parsedNode defines the serialization object to read data from
  32061. * @param scene defines the hosting scene
  32062. */
  32063. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  32064. /**
  32065. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  32066. * @param includeDescendants Include bounding info from descendants as well (true by default)
  32067. * @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
  32068. * @returns the new bounding vectors
  32069. */
  32070. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  32071. min: Vector3;
  32072. max: Vector3;
  32073. };
  32074. }
  32075. }
  32076. declare module BABYLON {
  32077. /**
  32078. * @hidden
  32079. */
  32080. export class _IAnimationState {
  32081. key: number;
  32082. repeatCount: number;
  32083. workValue?: any;
  32084. loopMode?: number;
  32085. offsetValue?: any;
  32086. highLimitValue?: any;
  32087. }
  32088. /**
  32089. * Class used to store any kind of animation
  32090. */
  32091. export class Animation {
  32092. /**Name of the animation */
  32093. name: string;
  32094. /**Property to animate */
  32095. targetProperty: string;
  32096. /**The frames per second of the animation */
  32097. framePerSecond: number;
  32098. /**The data type of the animation */
  32099. dataType: number;
  32100. /**The loop mode of the animation */
  32101. loopMode?: number | undefined;
  32102. /**Specifies if blending should be enabled */
  32103. enableBlending?: boolean | undefined;
  32104. /**
  32105. * Use matrix interpolation instead of using direct key value when animating matrices
  32106. */
  32107. static AllowMatricesInterpolation: boolean;
  32108. /**
  32109. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  32110. */
  32111. static AllowMatrixDecomposeForInterpolation: boolean;
  32112. /**
  32113. * Stores the key frames of the animation
  32114. */
  32115. private _keys;
  32116. /**
  32117. * Stores the easing function of the animation
  32118. */
  32119. private _easingFunction;
  32120. /**
  32121. * @hidden Internal use only
  32122. */
  32123. _runtimeAnimations: RuntimeAnimation[];
  32124. /**
  32125. * The set of event that will be linked to this animation
  32126. */
  32127. private _events;
  32128. /**
  32129. * Stores an array of target property paths
  32130. */
  32131. targetPropertyPath: string[];
  32132. /**
  32133. * Stores the blending speed of the animation
  32134. */
  32135. blendingSpeed: number;
  32136. /**
  32137. * Stores the animation ranges for the animation
  32138. */
  32139. private _ranges;
  32140. /**
  32141. * @hidden Internal use
  32142. */
  32143. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  32144. /**
  32145. * Sets up an animation
  32146. * @param property The property to animate
  32147. * @param animationType The animation type to apply
  32148. * @param framePerSecond The frames per second of the animation
  32149. * @param easingFunction The easing function used in the animation
  32150. * @returns The created animation
  32151. */
  32152. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  32153. /**
  32154. * Create and start an animation on a node
  32155. * @param name defines the name of the global animation that will be run on all nodes
  32156. * @param node defines the root node where the animation will take place
  32157. * @param targetProperty defines property to animate
  32158. * @param framePerSecond defines the number of frame per second yo use
  32159. * @param totalFrame defines the number of frames in total
  32160. * @param from defines the initial value
  32161. * @param to defines the final value
  32162. * @param loopMode defines which loop mode you want to use (off by default)
  32163. * @param easingFunction defines the easing function to use (linear by default)
  32164. * @param onAnimationEnd defines the callback to call when animation end
  32165. * @returns the animatable created for this animation
  32166. */
  32167. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32168. /**
  32169. * Create and start an animation on a node and its descendants
  32170. * @param name defines the name of the global animation that will be run on all nodes
  32171. * @param node defines the root node where the animation will take place
  32172. * @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
  32173. * @param targetProperty defines property to animate
  32174. * @param framePerSecond defines the number of frame per second to use
  32175. * @param totalFrame defines the number of frames in total
  32176. * @param from defines the initial value
  32177. * @param to defines the final value
  32178. * @param loopMode defines which loop mode you want to use (off by default)
  32179. * @param easingFunction defines the easing function to use (linear by default)
  32180. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  32181. * @returns the list of animatables created for all nodes
  32182. * @example https://www.babylonjs-playground.com/#MH0VLI
  32183. */
  32184. 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[]>;
  32185. /**
  32186. * Creates a new animation, merges it with the existing animations and starts it
  32187. * @param name Name of the animation
  32188. * @param node Node which contains the scene that begins the animations
  32189. * @param targetProperty Specifies which property to animate
  32190. * @param framePerSecond The frames per second of the animation
  32191. * @param totalFrame The total number of frames
  32192. * @param from The frame at the beginning of the animation
  32193. * @param to The frame at the end of the animation
  32194. * @param loopMode Specifies the loop mode of the animation
  32195. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  32196. * @param onAnimationEnd Callback to run once the animation is complete
  32197. * @returns Nullable animation
  32198. */
  32199. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32200. /**
  32201. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  32202. * @param sourceAnimation defines the Animation containing keyframes to convert
  32203. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  32204. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  32205. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  32206. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  32207. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  32208. */
  32209. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  32210. /**
  32211. * Transition property of an host to the target Value
  32212. * @param property The property to transition
  32213. * @param targetValue The target Value of the property
  32214. * @param host The object where the property to animate belongs
  32215. * @param scene Scene used to run the animation
  32216. * @param frameRate Framerate (in frame/s) to use
  32217. * @param transition The transition type we want to use
  32218. * @param duration The duration of the animation, in milliseconds
  32219. * @param onAnimationEnd Callback trigger at the end of the animation
  32220. * @returns Nullable animation
  32221. */
  32222. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  32223. /**
  32224. * Return the array of runtime animations currently using this animation
  32225. */
  32226. get runtimeAnimations(): RuntimeAnimation[];
  32227. /**
  32228. * Specifies if any of the runtime animations are currently running
  32229. */
  32230. get hasRunningRuntimeAnimations(): boolean;
  32231. /**
  32232. * Initializes the animation
  32233. * @param name Name of the animation
  32234. * @param targetProperty Property to animate
  32235. * @param framePerSecond The frames per second of the animation
  32236. * @param dataType The data type of the animation
  32237. * @param loopMode The loop mode of the animation
  32238. * @param enableBlending Specifies if blending should be enabled
  32239. */
  32240. constructor(
  32241. /**Name of the animation */
  32242. name: string,
  32243. /**Property to animate */
  32244. targetProperty: string,
  32245. /**The frames per second of the animation */
  32246. framePerSecond: number,
  32247. /**The data type of the animation */
  32248. dataType: number,
  32249. /**The loop mode of the animation */
  32250. loopMode?: number | undefined,
  32251. /**Specifies if blending should be enabled */
  32252. enableBlending?: boolean | undefined);
  32253. /**
  32254. * Converts the animation to a string
  32255. * @param fullDetails support for multiple levels of logging within scene loading
  32256. * @returns String form of the animation
  32257. */
  32258. toString(fullDetails?: boolean): string;
  32259. /**
  32260. * Add an event to this animation
  32261. * @param event Event to add
  32262. */
  32263. addEvent(event: AnimationEvent): void;
  32264. /**
  32265. * Remove all events found at the given frame
  32266. * @param frame The frame to remove events from
  32267. */
  32268. removeEvents(frame: number): void;
  32269. /**
  32270. * Retrieves all the events from the animation
  32271. * @returns Events from the animation
  32272. */
  32273. getEvents(): AnimationEvent[];
  32274. /**
  32275. * Creates an animation range
  32276. * @param name Name of the animation range
  32277. * @param from Starting frame of the animation range
  32278. * @param to Ending frame of the animation
  32279. */
  32280. createRange(name: string, from: number, to: number): void;
  32281. /**
  32282. * Deletes an animation range by name
  32283. * @param name Name of the animation range to delete
  32284. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  32285. */
  32286. deleteRange(name: string, deleteFrames?: boolean): void;
  32287. /**
  32288. * Gets the animation range by name, or null if not defined
  32289. * @param name Name of the animation range
  32290. * @returns Nullable animation range
  32291. */
  32292. getRange(name: string): Nullable<AnimationRange>;
  32293. /**
  32294. * Gets the key frames from the animation
  32295. * @returns The key frames of the animation
  32296. */
  32297. getKeys(): Array<IAnimationKey>;
  32298. /**
  32299. * Gets the highest frame rate of the animation
  32300. * @returns Highest frame rate of the animation
  32301. */
  32302. getHighestFrame(): number;
  32303. /**
  32304. * Gets the easing function of the animation
  32305. * @returns Easing function of the animation
  32306. */
  32307. getEasingFunction(): IEasingFunction;
  32308. /**
  32309. * Sets the easing function of the animation
  32310. * @param easingFunction A custom mathematical formula for animation
  32311. */
  32312. setEasingFunction(easingFunction: EasingFunction): void;
  32313. /**
  32314. * Interpolates a scalar linearly
  32315. * @param startValue Start value of the animation curve
  32316. * @param endValue End value of the animation curve
  32317. * @param gradient Scalar amount to interpolate
  32318. * @returns Interpolated scalar value
  32319. */
  32320. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  32321. /**
  32322. * Interpolates a scalar cubically
  32323. * @param startValue Start value of the animation curve
  32324. * @param outTangent End tangent of the animation
  32325. * @param endValue End value of the animation curve
  32326. * @param inTangent Start tangent of the animation curve
  32327. * @param gradient Scalar amount to interpolate
  32328. * @returns Interpolated scalar value
  32329. */
  32330. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  32331. /**
  32332. * Interpolates a quaternion using a spherical linear interpolation
  32333. * @param startValue Start value of the animation curve
  32334. * @param endValue End value of the animation curve
  32335. * @param gradient Scalar amount to interpolate
  32336. * @returns Interpolated quaternion value
  32337. */
  32338. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  32339. /**
  32340. * Interpolates a quaternion cubically
  32341. * @param startValue Start value of the animation curve
  32342. * @param outTangent End tangent of the animation curve
  32343. * @param endValue End value of the animation curve
  32344. * @param inTangent Start tangent of the animation curve
  32345. * @param gradient Scalar amount to interpolate
  32346. * @returns Interpolated quaternion value
  32347. */
  32348. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  32349. /**
  32350. * Interpolates a Vector3 linearl
  32351. * @param startValue Start value of the animation curve
  32352. * @param endValue End value of the animation curve
  32353. * @param gradient Scalar amount to interpolate
  32354. * @returns Interpolated scalar value
  32355. */
  32356. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  32357. /**
  32358. * Interpolates a Vector3 cubically
  32359. * @param startValue Start value of the animation curve
  32360. * @param outTangent End tangent of the animation
  32361. * @param endValue End value of the animation curve
  32362. * @param inTangent Start tangent of the animation curve
  32363. * @param gradient Scalar amount to interpolate
  32364. * @returns InterpolatedVector3 value
  32365. */
  32366. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  32367. /**
  32368. * Interpolates a Vector2 linearly
  32369. * @param startValue Start value of the animation curve
  32370. * @param endValue End value of the animation curve
  32371. * @param gradient Scalar amount to interpolate
  32372. * @returns Interpolated Vector2 value
  32373. */
  32374. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  32375. /**
  32376. * Interpolates a Vector2 cubically
  32377. * @param startValue Start value of the animation curve
  32378. * @param outTangent End tangent of the animation
  32379. * @param endValue End value of the animation curve
  32380. * @param inTangent Start tangent of the animation curve
  32381. * @param gradient Scalar amount to interpolate
  32382. * @returns Interpolated Vector2 value
  32383. */
  32384. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  32385. /**
  32386. * Interpolates a size linearly
  32387. * @param startValue Start value of the animation curve
  32388. * @param endValue End value of the animation curve
  32389. * @param gradient Scalar amount to interpolate
  32390. * @returns Interpolated Size value
  32391. */
  32392. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  32393. /**
  32394. * Interpolates a Color3 linearly
  32395. * @param startValue Start value of the animation curve
  32396. * @param endValue End value of the animation curve
  32397. * @param gradient Scalar amount to interpolate
  32398. * @returns Interpolated Color3 value
  32399. */
  32400. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  32401. /**
  32402. * Interpolates a Color4 linearly
  32403. * @param startValue Start value of the animation curve
  32404. * @param endValue End value of the animation curve
  32405. * @param gradient Scalar amount to interpolate
  32406. * @returns Interpolated Color3 value
  32407. */
  32408. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  32409. /**
  32410. * @hidden Internal use only
  32411. */
  32412. _getKeyValue(value: any): any;
  32413. /**
  32414. * @hidden Internal use only
  32415. */
  32416. _interpolate(currentFrame: number, state: _IAnimationState): any;
  32417. /**
  32418. * Defines the function to use to interpolate matrices
  32419. * @param startValue defines the start matrix
  32420. * @param endValue defines the end matrix
  32421. * @param gradient defines the gradient between both matrices
  32422. * @param result defines an optional target matrix where to store the interpolation
  32423. * @returns the interpolated matrix
  32424. */
  32425. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  32426. /**
  32427. * Makes a copy of the animation
  32428. * @returns Cloned animation
  32429. */
  32430. clone(): Animation;
  32431. /**
  32432. * Sets the key frames of the animation
  32433. * @param values The animation key frames to set
  32434. */
  32435. setKeys(values: Array<IAnimationKey>): void;
  32436. /**
  32437. * Serializes the animation to an object
  32438. * @returns Serialized object
  32439. */
  32440. serialize(): any;
  32441. /**
  32442. * Float animation type
  32443. */
  32444. static readonly ANIMATIONTYPE_FLOAT: number;
  32445. /**
  32446. * Vector3 animation type
  32447. */
  32448. static readonly ANIMATIONTYPE_VECTOR3: number;
  32449. /**
  32450. * Quaternion animation type
  32451. */
  32452. static readonly ANIMATIONTYPE_QUATERNION: number;
  32453. /**
  32454. * Matrix animation type
  32455. */
  32456. static readonly ANIMATIONTYPE_MATRIX: number;
  32457. /**
  32458. * Color3 animation type
  32459. */
  32460. static readonly ANIMATIONTYPE_COLOR3: number;
  32461. /**
  32462. * Color3 animation type
  32463. */
  32464. static readonly ANIMATIONTYPE_COLOR4: number;
  32465. /**
  32466. * Vector2 animation type
  32467. */
  32468. static readonly ANIMATIONTYPE_VECTOR2: number;
  32469. /**
  32470. * Size animation type
  32471. */
  32472. static readonly ANIMATIONTYPE_SIZE: number;
  32473. /**
  32474. * Relative Loop Mode
  32475. */
  32476. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  32477. /**
  32478. * Cycle Loop Mode
  32479. */
  32480. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  32481. /**
  32482. * Constant Loop Mode
  32483. */
  32484. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  32485. /** @hidden */
  32486. static _UniversalLerp(left: any, right: any, amount: number): any;
  32487. /**
  32488. * Parses an animation object and creates an animation
  32489. * @param parsedAnimation Parsed animation object
  32490. * @returns Animation object
  32491. */
  32492. static Parse(parsedAnimation: any): Animation;
  32493. /**
  32494. * Appends the serialized animations from the source animations
  32495. * @param source Source containing the animations
  32496. * @param destination Target to store the animations
  32497. */
  32498. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32499. }
  32500. }
  32501. declare module BABYLON {
  32502. /**
  32503. * Interface containing an array of animations
  32504. */
  32505. export interface IAnimatable {
  32506. /**
  32507. * Array of animations
  32508. */
  32509. animations: Nullable<Array<Animation>>;
  32510. }
  32511. }
  32512. declare module BABYLON {
  32513. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  32514. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32515. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32516. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32517. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32518. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32519. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32520. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32521. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32522. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32523. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32524. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32525. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32526. /**
  32527. * Decorator used to define property that can be serialized as reference to a camera
  32528. * @param sourceName defines the name of the property to decorate
  32529. */
  32530. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32531. /**
  32532. * Class used to help serialization objects
  32533. */
  32534. export class SerializationHelper {
  32535. /** @hidden */
  32536. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  32537. /** @hidden */
  32538. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  32539. /** @hidden */
  32540. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  32541. /** @hidden */
  32542. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  32543. /**
  32544. * Appends the serialized animations from the source animations
  32545. * @param source Source containing the animations
  32546. * @param destination Target to store the animations
  32547. */
  32548. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32549. /**
  32550. * Static function used to serialized a specific entity
  32551. * @param entity defines the entity to serialize
  32552. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  32553. * @returns a JSON compatible object representing the serialization of the entity
  32554. */
  32555. static Serialize<T>(entity: T, serializationObject?: any): any;
  32556. /**
  32557. * Creates a new entity from a serialization data object
  32558. * @param creationFunction defines a function used to instanciated the new entity
  32559. * @param source defines the source serialization data
  32560. * @param scene defines the hosting scene
  32561. * @param rootUrl defines the root url for resources
  32562. * @returns a new entity
  32563. */
  32564. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  32565. /**
  32566. * Clones an object
  32567. * @param creationFunction defines the function used to instanciate the new object
  32568. * @param source defines the source object
  32569. * @returns the cloned object
  32570. */
  32571. static Clone<T>(creationFunction: () => T, source: T): T;
  32572. /**
  32573. * Instanciates a new object based on a source one (some data will be shared between both object)
  32574. * @param creationFunction defines the function used to instanciate the new object
  32575. * @param source defines the source object
  32576. * @returns the new object
  32577. */
  32578. static Instanciate<T>(creationFunction: () => T, source: T): T;
  32579. }
  32580. }
  32581. declare module BABYLON {
  32582. /**
  32583. * Base class of all the textures in babylon.
  32584. * It groups all the common properties the materials, post process, lights... might need
  32585. * in order to make a correct use of the texture.
  32586. */
  32587. export class BaseTexture implements IAnimatable {
  32588. /**
  32589. * Default anisotropic filtering level for the application.
  32590. * It is set to 4 as a good tradeoff between perf and quality.
  32591. */
  32592. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  32593. /**
  32594. * Gets or sets the unique id of the texture
  32595. */
  32596. uniqueId: number;
  32597. /**
  32598. * Define the name of the texture.
  32599. */
  32600. name: string;
  32601. /**
  32602. * Gets or sets an object used to store user defined information.
  32603. */
  32604. metadata: any;
  32605. /**
  32606. * For internal use only. Please do not use.
  32607. */
  32608. reservedDataStore: any;
  32609. private _hasAlpha;
  32610. /**
  32611. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  32612. */
  32613. set hasAlpha(value: boolean);
  32614. get hasAlpha(): boolean;
  32615. /**
  32616. * Defines if the alpha value should be determined via the rgb values.
  32617. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  32618. */
  32619. getAlphaFromRGB: boolean;
  32620. /**
  32621. * Intensity or strength of the texture.
  32622. * It is commonly used by materials to fine tune the intensity of the texture
  32623. */
  32624. level: number;
  32625. /**
  32626. * Define the UV chanel to use starting from 0 and defaulting to 0.
  32627. * This is part of the texture as textures usually maps to one uv set.
  32628. */
  32629. coordinatesIndex: number;
  32630. private _coordinatesMode;
  32631. /**
  32632. * How a texture is mapped.
  32633. *
  32634. * | Value | Type | Description |
  32635. * | ----- | ----------------------------------- | ----------- |
  32636. * | 0 | EXPLICIT_MODE | |
  32637. * | 1 | SPHERICAL_MODE | |
  32638. * | 2 | PLANAR_MODE | |
  32639. * | 3 | CUBIC_MODE | |
  32640. * | 4 | PROJECTION_MODE | |
  32641. * | 5 | SKYBOX_MODE | |
  32642. * | 6 | INVCUBIC_MODE | |
  32643. * | 7 | EQUIRECTANGULAR_MODE | |
  32644. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  32645. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  32646. */
  32647. set coordinatesMode(value: number);
  32648. get coordinatesMode(): number;
  32649. /**
  32650. * | Value | Type | Description |
  32651. * | ----- | ------------------ | ----------- |
  32652. * | 0 | CLAMP_ADDRESSMODE | |
  32653. * | 1 | WRAP_ADDRESSMODE | |
  32654. * | 2 | MIRROR_ADDRESSMODE | |
  32655. */
  32656. wrapU: number;
  32657. /**
  32658. * | Value | Type | Description |
  32659. * | ----- | ------------------ | ----------- |
  32660. * | 0 | CLAMP_ADDRESSMODE | |
  32661. * | 1 | WRAP_ADDRESSMODE | |
  32662. * | 2 | MIRROR_ADDRESSMODE | |
  32663. */
  32664. wrapV: number;
  32665. /**
  32666. * | Value | Type | Description |
  32667. * | ----- | ------------------ | ----------- |
  32668. * | 0 | CLAMP_ADDRESSMODE | |
  32669. * | 1 | WRAP_ADDRESSMODE | |
  32670. * | 2 | MIRROR_ADDRESSMODE | |
  32671. */
  32672. wrapR: number;
  32673. /**
  32674. * With compliant hardware and browser (supporting anisotropic filtering)
  32675. * this defines the level of anisotropic filtering in the texture.
  32676. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  32677. */
  32678. anisotropicFilteringLevel: number;
  32679. /**
  32680. * Define if the texture is a cube texture or if false a 2d texture.
  32681. */
  32682. get isCube(): boolean;
  32683. set isCube(value: boolean);
  32684. /**
  32685. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  32686. */
  32687. get is3D(): boolean;
  32688. set is3D(value: boolean);
  32689. /**
  32690. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  32691. */
  32692. get is2DArray(): boolean;
  32693. set is2DArray(value: boolean);
  32694. /**
  32695. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  32696. * HDR texture are usually stored in linear space.
  32697. * This only impacts the PBR and Background materials
  32698. */
  32699. gammaSpace: boolean;
  32700. /**
  32701. * Gets or sets whether or not the texture contains RGBD data.
  32702. */
  32703. get isRGBD(): boolean;
  32704. set isRGBD(value: boolean);
  32705. /**
  32706. * Is Z inverted in the texture (useful in a cube texture).
  32707. */
  32708. invertZ: boolean;
  32709. /**
  32710. * Are mip maps generated for this texture or not.
  32711. */
  32712. get noMipmap(): boolean;
  32713. /**
  32714. * @hidden
  32715. */
  32716. lodLevelInAlpha: boolean;
  32717. /**
  32718. * With prefiltered texture, defined the offset used during the prefiltering steps.
  32719. */
  32720. get lodGenerationOffset(): number;
  32721. set lodGenerationOffset(value: number);
  32722. /**
  32723. * With prefiltered texture, defined the scale used during the prefiltering steps.
  32724. */
  32725. get lodGenerationScale(): number;
  32726. set lodGenerationScale(value: number);
  32727. /**
  32728. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  32729. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  32730. * average roughness values.
  32731. */
  32732. get linearSpecularLOD(): boolean;
  32733. set linearSpecularLOD(value: boolean);
  32734. /**
  32735. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  32736. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  32737. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  32738. */
  32739. get irradianceTexture(): Nullable<BaseTexture>;
  32740. set irradianceTexture(value: Nullable<BaseTexture>);
  32741. /**
  32742. * Define if the texture is a render target.
  32743. */
  32744. isRenderTarget: boolean;
  32745. /**
  32746. * Define the unique id of the texture in the scene.
  32747. */
  32748. get uid(): string;
  32749. /**
  32750. * Return a string representation of the texture.
  32751. * @returns the texture as a string
  32752. */
  32753. toString(): string;
  32754. /**
  32755. * Get the class name of the texture.
  32756. * @returns "BaseTexture"
  32757. */
  32758. getClassName(): string;
  32759. private _realTimeFiltering;
  32760. /**
  32761. * Enables realtime filtering on the texture.
  32762. */
  32763. get realTimeFiltering(): boolean;
  32764. set realTimeFiltering(b: boolean);
  32765. private _realTimeFilteringQuality;
  32766. /**
  32767. * Quality switch for realtime filtering
  32768. */
  32769. get realTimeFilteringQuality(): number;
  32770. set realTimeFilteringQuality(n: number);
  32771. /**
  32772. * Define the list of animation attached to the texture.
  32773. */
  32774. animations: Animation[];
  32775. /**
  32776. * An event triggered when the texture is disposed.
  32777. */
  32778. onDisposeObservable: Observable<BaseTexture>;
  32779. private _onDisposeObserver;
  32780. /**
  32781. * Callback triggered when the texture has been disposed.
  32782. * Kept for back compatibility, you can use the onDisposeObservable instead.
  32783. */
  32784. set onDispose(callback: () => void);
  32785. /**
  32786. * Define the current state of the loading sequence when in delayed load mode.
  32787. */
  32788. delayLoadState: number;
  32789. private _scene;
  32790. private _engine;
  32791. /** @hidden */
  32792. _texture: Nullable<InternalTexture>;
  32793. private _uid;
  32794. /**
  32795. * Define if the texture is preventinga material to render or not.
  32796. * If not and the texture is not ready, the engine will use a default black texture instead.
  32797. */
  32798. get isBlocking(): boolean;
  32799. /**
  32800. * Instantiates a new BaseTexture.
  32801. * Base class of all the textures in babylon.
  32802. * It groups all the common properties the materials, post process, lights... might need
  32803. * in order to make a correct use of the texture.
  32804. * @param sceneOrEngine Define the scene or engine the texture blongs to
  32805. */
  32806. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  32807. /**
  32808. * Get the scene the texture belongs to.
  32809. * @returns the scene or null if undefined
  32810. */
  32811. getScene(): Nullable<Scene>;
  32812. /** @hidden */
  32813. protected _getEngine(): Nullable<ThinEngine>;
  32814. /**
  32815. * Get the texture transform matrix used to offset tile the texture for istance.
  32816. * @returns the transformation matrix
  32817. */
  32818. getTextureMatrix(): Matrix;
  32819. /**
  32820. * Get the texture reflection matrix used to rotate/transform the reflection.
  32821. * @returns the reflection matrix
  32822. */
  32823. getReflectionTextureMatrix(): Matrix;
  32824. /**
  32825. * Get the underlying lower level texture from Babylon.
  32826. * @returns the insternal texture
  32827. */
  32828. getInternalTexture(): Nullable<InternalTexture>;
  32829. /**
  32830. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  32831. * @returns true if ready or not blocking
  32832. */
  32833. isReadyOrNotBlocking(): boolean;
  32834. /**
  32835. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  32836. * @returns true if fully ready
  32837. */
  32838. isReady(): boolean;
  32839. private _cachedSize;
  32840. /**
  32841. * Get the size of the texture.
  32842. * @returns the texture size.
  32843. */
  32844. getSize(): ISize;
  32845. /**
  32846. * Get the base size of the texture.
  32847. * It can be different from the size if the texture has been resized for POT for instance
  32848. * @returns the base size
  32849. */
  32850. getBaseSize(): ISize;
  32851. /**
  32852. * Update the sampling mode of the texture.
  32853. * Default is Trilinear mode.
  32854. *
  32855. * | Value | Type | Description |
  32856. * | ----- | ------------------ | ----------- |
  32857. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  32858. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  32859. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  32860. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  32861. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  32862. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  32863. * | 7 | NEAREST_LINEAR | |
  32864. * | 8 | NEAREST_NEAREST | |
  32865. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  32866. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  32867. * | 11 | LINEAR_LINEAR | |
  32868. * | 12 | LINEAR_NEAREST | |
  32869. *
  32870. * > _mag_: magnification filter (close to the viewer)
  32871. * > _min_: minification filter (far from the viewer)
  32872. * > _mip_: filter used between mip map levels
  32873. *@param samplingMode Define the new sampling mode of the texture
  32874. */
  32875. updateSamplingMode(samplingMode: number): void;
  32876. /**
  32877. * Scales the texture if is `canRescale()`
  32878. * @param ratio the resize factor we want to use to rescale
  32879. */
  32880. scale(ratio: number): void;
  32881. /**
  32882. * Get if the texture can rescale.
  32883. */
  32884. get canRescale(): boolean;
  32885. /** @hidden */
  32886. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  32887. /** @hidden */
  32888. _rebuild(): void;
  32889. /**
  32890. * Triggers the load sequence in delayed load mode.
  32891. */
  32892. delayLoad(): void;
  32893. /**
  32894. * Clones the texture.
  32895. * @returns the cloned texture
  32896. */
  32897. clone(): Nullable<BaseTexture>;
  32898. /**
  32899. * Get the texture underlying type (INT, FLOAT...)
  32900. */
  32901. get textureType(): number;
  32902. /**
  32903. * Get the texture underlying format (RGB, RGBA...)
  32904. */
  32905. get textureFormat(): number;
  32906. /**
  32907. * Indicates that textures need to be re-calculated for all materials
  32908. */
  32909. protected _markAllSubMeshesAsTexturesDirty(): void;
  32910. /**
  32911. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  32912. * This will returns an RGBA array buffer containing either in values (0-255) or
  32913. * float values (0-1) depending of the underlying buffer type.
  32914. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  32915. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  32916. * @param buffer defines a user defined buffer to fill with data (can be null)
  32917. * @returns The Array buffer containing the pixels data.
  32918. */
  32919. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  32920. /**
  32921. * Release and destroy the underlying lower level texture aka internalTexture.
  32922. */
  32923. releaseInternalTexture(): void;
  32924. /** @hidden */
  32925. get _lodTextureHigh(): Nullable<BaseTexture>;
  32926. /** @hidden */
  32927. get _lodTextureMid(): Nullable<BaseTexture>;
  32928. /** @hidden */
  32929. get _lodTextureLow(): Nullable<BaseTexture>;
  32930. /**
  32931. * Dispose the texture and release its associated resources.
  32932. */
  32933. dispose(): void;
  32934. /**
  32935. * Serialize the texture into a JSON representation that can be parsed later on.
  32936. * @returns the JSON representation of the texture
  32937. */
  32938. serialize(): any;
  32939. /**
  32940. * Helper function to be called back once a list of texture contains only ready textures.
  32941. * @param textures Define the list of textures to wait for
  32942. * @param callback Define the callback triggered once the entire list will be ready
  32943. */
  32944. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  32945. private static _isScene;
  32946. }
  32947. }
  32948. declare module BABYLON {
  32949. /**
  32950. * Options to be used when creating an effect.
  32951. */
  32952. export interface IEffectCreationOptions {
  32953. /**
  32954. * Atrributes that will be used in the shader.
  32955. */
  32956. attributes: string[];
  32957. /**
  32958. * Uniform varible names that will be set in the shader.
  32959. */
  32960. uniformsNames: string[];
  32961. /**
  32962. * Uniform buffer variable names that will be set in the shader.
  32963. */
  32964. uniformBuffersNames: string[];
  32965. /**
  32966. * Sampler texture variable names that will be set in the shader.
  32967. */
  32968. samplers: string[];
  32969. /**
  32970. * Define statements that will be set in the shader.
  32971. */
  32972. defines: any;
  32973. /**
  32974. * Possible fallbacks for this effect to improve performance when needed.
  32975. */
  32976. fallbacks: Nullable<IEffectFallbacks>;
  32977. /**
  32978. * Callback that will be called when the shader is compiled.
  32979. */
  32980. onCompiled: Nullable<(effect: Effect) => void>;
  32981. /**
  32982. * Callback that will be called if an error occurs during shader compilation.
  32983. */
  32984. onError: Nullable<(effect: Effect, errors: string) => void>;
  32985. /**
  32986. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  32987. */
  32988. indexParameters?: any;
  32989. /**
  32990. * Max number of lights that can be used in the shader.
  32991. */
  32992. maxSimultaneousLights?: number;
  32993. /**
  32994. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  32995. */
  32996. transformFeedbackVaryings?: Nullable<string[]>;
  32997. }
  32998. /**
  32999. * Effect containing vertex and fragment shader that can be executed on an object.
  33000. */
  33001. export class Effect implements IDisposable {
  33002. /**
  33003. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  33004. */
  33005. static ShadersRepository: string;
  33006. /**
  33007. * Enable logging of the shader code when a compilation error occurs
  33008. */
  33009. static LogShaderCodeOnCompilationError: boolean;
  33010. /**
  33011. * Name of the effect.
  33012. */
  33013. name: any;
  33014. /**
  33015. * String container all the define statements that should be set on the shader.
  33016. */
  33017. defines: string;
  33018. /**
  33019. * Callback that will be called when the shader is compiled.
  33020. */
  33021. onCompiled: Nullable<(effect: Effect) => void>;
  33022. /**
  33023. * Callback that will be called if an error occurs during shader compilation.
  33024. */
  33025. onError: Nullable<(effect: Effect, errors: string) => void>;
  33026. /**
  33027. * Callback that will be called when effect is bound.
  33028. */
  33029. onBind: Nullable<(effect: Effect) => void>;
  33030. /**
  33031. * Unique ID of the effect.
  33032. */
  33033. uniqueId: number;
  33034. /**
  33035. * Observable that will be called when the shader is compiled.
  33036. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  33037. */
  33038. onCompileObservable: Observable<Effect>;
  33039. /**
  33040. * Observable that will be called if an error occurs during shader compilation.
  33041. */
  33042. onErrorObservable: Observable<Effect>;
  33043. /** @hidden */
  33044. _onBindObservable: Nullable<Observable<Effect>>;
  33045. /**
  33046. * @hidden
  33047. * Specifies if the effect was previously ready
  33048. */
  33049. _wasPreviouslyReady: boolean;
  33050. /**
  33051. * Observable that will be called when effect is bound.
  33052. */
  33053. get onBindObservable(): Observable<Effect>;
  33054. /** @hidden */
  33055. _bonesComputationForcedToCPU: boolean;
  33056. private static _uniqueIdSeed;
  33057. private _engine;
  33058. private _uniformBuffersNames;
  33059. private _uniformBuffersNamesList;
  33060. private _uniformsNames;
  33061. private _samplerList;
  33062. private _samplers;
  33063. private _isReady;
  33064. private _compilationError;
  33065. private _allFallbacksProcessed;
  33066. private _attributesNames;
  33067. private _attributes;
  33068. private _attributeLocationByName;
  33069. private _uniforms;
  33070. /**
  33071. * Key for the effect.
  33072. * @hidden
  33073. */
  33074. _key: string;
  33075. private _indexParameters;
  33076. private _fallbacks;
  33077. private _vertexSourceCode;
  33078. private _fragmentSourceCode;
  33079. private _vertexSourceCodeOverride;
  33080. private _fragmentSourceCodeOverride;
  33081. private _transformFeedbackVaryings;
  33082. /**
  33083. * Compiled shader to webGL program.
  33084. * @hidden
  33085. */
  33086. _pipelineContext: Nullable<IPipelineContext>;
  33087. private _valueCache;
  33088. private static _baseCache;
  33089. /**
  33090. * Instantiates an effect.
  33091. * An effect can be used to create/manage/execute vertex and fragment shaders.
  33092. * @param baseName Name of the effect.
  33093. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  33094. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  33095. * @param samplers List of sampler variables that will be passed to the shader.
  33096. * @param engine Engine to be used to render the effect
  33097. * @param defines Define statements to be added to the shader.
  33098. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  33099. * @param onCompiled Callback that will be called when the shader is compiled.
  33100. * @param onError Callback that will be called if an error occurs during shader compilation.
  33101. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33102. */
  33103. 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);
  33104. private _useFinalCode;
  33105. /**
  33106. * Unique key for this effect
  33107. */
  33108. get key(): string;
  33109. /**
  33110. * If the effect has been compiled and prepared.
  33111. * @returns if the effect is compiled and prepared.
  33112. */
  33113. isReady(): boolean;
  33114. private _isReadyInternal;
  33115. /**
  33116. * The engine the effect was initialized with.
  33117. * @returns the engine.
  33118. */
  33119. getEngine(): Engine;
  33120. /**
  33121. * The pipeline context for this effect
  33122. * @returns the associated pipeline context
  33123. */
  33124. getPipelineContext(): Nullable<IPipelineContext>;
  33125. /**
  33126. * The set of names of attribute variables for the shader.
  33127. * @returns An array of attribute names.
  33128. */
  33129. getAttributesNames(): string[];
  33130. /**
  33131. * Returns the attribute at the given index.
  33132. * @param index The index of the attribute.
  33133. * @returns The location of the attribute.
  33134. */
  33135. getAttributeLocation(index: number): number;
  33136. /**
  33137. * Returns the attribute based on the name of the variable.
  33138. * @param name of the attribute to look up.
  33139. * @returns the attribute location.
  33140. */
  33141. getAttributeLocationByName(name: string): number;
  33142. /**
  33143. * The number of attributes.
  33144. * @returns the numnber of attributes.
  33145. */
  33146. getAttributesCount(): number;
  33147. /**
  33148. * Gets the index of a uniform variable.
  33149. * @param uniformName of the uniform to look up.
  33150. * @returns the index.
  33151. */
  33152. getUniformIndex(uniformName: string): number;
  33153. /**
  33154. * Returns the attribute based on the name of the variable.
  33155. * @param uniformName of the uniform to look up.
  33156. * @returns the location of the uniform.
  33157. */
  33158. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  33159. /**
  33160. * Returns an array of sampler variable names
  33161. * @returns The array of sampler variable names.
  33162. */
  33163. getSamplers(): string[];
  33164. /**
  33165. * Returns an array of uniform variable names
  33166. * @returns The array of uniform variable names.
  33167. */
  33168. getUniformNames(): string[];
  33169. /**
  33170. * Returns an array of uniform buffer variable names
  33171. * @returns The array of uniform buffer variable names.
  33172. */
  33173. getUniformBuffersNames(): string[];
  33174. /**
  33175. * Returns the index parameters used to create the effect
  33176. * @returns The index parameters object
  33177. */
  33178. getIndexParameters(): any;
  33179. /**
  33180. * The error from the last compilation.
  33181. * @returns the error string.
  33182. */
  33183. getCompilationError(): string;
  33184. /**
  33185. * Gets a boolean indicating that all fallbacks were used during compilation
  33186. * @returns true if all fallbacks were used
  33187. */
  33188. allFallbacksProcessed(): boolean;
  33189. /**
  33190. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  33191. * @param func The callback to be used.
  33192. */
  33193. executeWhenCompiled(func: (effect: Effect) => void): void;
  33194. private _checkIsReady;
  33195. private _loadShader;
  33196. /**
  33197. * Gets the vertex shader source code of this effect
  33198. */
  33199. get vertexSourceCode(): string;
  33200. /**
  33201. * Gets the fragment shader source code of this effect
  33202. */
  33203. get fragmentSourceCode(): string;
  33204. /**
  33205. * Recompiles the webGL program
  33206. * @param vertexSourceCode The source code for the vertex shader.
  33207. * @param fragmentSourceCode The source code for the fragment shader.
  33208. * @param onCompiled Callback called when completed.
  33209. * @param onError Callback called on error.
  33210. * @hidden
  33211. */
  33212. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  33213. /**
  33214. * Prepares the effect
  33215. * @hidden
  33216. */
  33217. _prepareEffect(): void;
  33218. private _getShaderCodeAndErrorLine;
  33219. private _processCompilationErrors;
  33220. /**
  33221. * Checks if the effect is supported. (Must be called after compilation)
  33222. */
  33223. get isSupported(): boolean;
  33224. /**
  33225. * Binds a texture to the engine to be used as output of the shader.
  33226. * @param channel Name of the output variable.
  33227. * @param texture Texture to bind.
  33228. * @hidden
  33229. */
  33230. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  33231. /**
  33232. * Sets a texture on the engine to be used in the shader.
  33233. * @param channel Name of the sampler variable.
  33234. * @param texture Texture to set.
  33235. */
  33236. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  33237. /**
  33238. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  33239. * @param channel Name of the sampler variable.
  33240. * @param texture Texture to set.
  33241. */
  33242. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  33243. /**
  33244. * Sets an array of textures on the engine to be used in the shader.
  33245. * @param channel Name of the variable.
  33246. * @param textures Textures to set.
  33247. */
  33248. setTextureArray(channel: string, textures: BaseTexture[]): void;
  33249. /**
  33250. * 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)
  33251. * @param channel Name of the sampler variable.
  33252. * @param postProcess Post process to get the input texture from.
  33253. */
  33254. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  33255. /**
  33256. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  33257. * 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)
  33258. * @param channel Name of the sampler variable.
  33259. * @param postProcess Post process to get the output texture from.
  33260. */
  33261. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  33262. /** @hidden */
  33263. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  33264. /** @hidden */
  33265. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  33266. /** @hidden */
  33267. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  33268. /** @hidden */
  33269. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  33270. /**
  33271. * Binds a buffer to a uniform.
  33272. * @param buffer Buffer to bind.
  33273. * @param name Name of the uniform variable to bind to.
  33274. */
  33275. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  33276. /**
  33277. * Binds block to a uniform.
  33278. * @param blockName Name of the block to bind.
  33279. * @param index Index to bind.
  33280. */
  33281. bindUniformBlock(blockName: string, index: number): void;
  33282. /**
  33283. * Sets an interger value on a uniform variable.
  33284. * @param uniformName Name of the variable.
  33285. * @param value Value to be set.
  33286. * @returns this effect.
  33287. */
  33288. setInt(uniformName: string, value: number): Effect;
  33289. /**
  33290. * Sets an int array on a uniform variable.
  33291. * @param uniformName Name of the variable.
  33292. * @param array array to be set.
  33293. * @returns this effect.
  33294. */
  33295. setIntArray(uniformName: string, array: Int32Array): Effect;
  33296. /**
  33297. * 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)
  33298. * @param uniformName Name of the variable.
  33299. * @param array array to be set.
  33300. * @returns this effect.
  33301. */
  33302. setIntArray2(uniformName: string, array: Int32Array): Effect;
  33303. /**
  33304. * 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)
  33305. * @param uniformName Name of the variable.
  33306. * @param array array to be set.
  33307. * @returns this effect.
  33308. */
  33309. setIntArray3(uniformName: string, array: Int32Array): Effect;
  33310. /**
  33311. * 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)
  33312. * @param uniformName Name of the variable.
  33313. * @param array array to be set.
  33314. * @returns this effect.
  33315. */
  33316. setIntArray4(uniformName: string, array: Int32Array): Effect;
  33317. /**
  33318. * Sets an float array on a uniform variable.
  33319. * @param uniformName Name of the variable.
  33320. * @param array array to be set.
  33321. * @returns this effect.
  33322. */
  33323. setFloatArray(uniformName: string, array: Float32Array): Effect;
  33324. /**
  33325. * 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)
  33326. * @param uniformName Name of the variable.
  33327. * @param array array to be set.
  33328. * @returns this effect.
  33329. */
  33330. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  33331. /**
  33332. * 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)
  33333. * @param uniformName Name of the variable.
  33334. * @param array array to be set.
  33335. * @returns this effect.
  33336. */
  33337. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  33338. /**
  33339. * 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)
  33340. * @param uniformName Name of the variable.
  33341. * @param array array to be set.
  33342. * @returns this effect.
  33343. */
  33344. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  33345. /**
  33346. * Sets an array on a uniform variable.
  33347. * @param uniformName Name of the variable.
  33348. * @param array array to be set.
  33349. * @returns this effect.
  33350. */
  33351. setArray(uniformName: string, array: number[]): Effect;
  33352. /**
  33353. * 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)
  33354. * @param uniformName Name of the variable.
  33355. * @param array array to be set.
  33356. * @returns this effect.
  33357. */
  33358. setArray2(uniformName: string, array: number[]): Effect;
  33359. /**
  33360. * 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)
  33361. * @param uniformName Name of the variable.
  33362. * @param array array to be set.
  33363. * @returns this effect.
  33364. */
  33365. setArray3(uniformName: string, array: number[]): Effect;
  33366. /**
  33367. * 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)
  33368. * @param uniformName Name of the variable.
  33369. * @param array array to be set.
  33370. * @returns this effect.
  33371. */
  33372. setArray4(uniformName: string, array: number[]): Effect;
  33373. /**
  33374. * Sets matrices on a uniform variable.
  33375. * @param uniformName Name of the variable.
  33376. * @param matrices matrices to be set.
  33377. * @returns this effect.
  33378. */
  33379. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  33380. /**
  33381. * Sets matrix on a uniform variable.
  33382. * @param uniformName Name of the variable.
  33383. * @param matrix matrix to be set.
  33384. * @returns this effect.
  33385. */
  33386. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  33387. /**
  33388. * 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)
  33389. * @param uniformName Name of the variable.
  33390. * @param matrix matrix to be set.
  33391. * @returns this effect.
  33392. */
  33393. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  33394. /**
  33395. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  33396. * @param uniformName Name of the variable.
  33397. * @param matrix matrix to be set.
  33398. * @returns this effect.
  33399. */
  33400. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  33401. /**
  33402. * Sets a float on a uniform variable.
  33403. * @param uniformName Name of the variable.
  33404. * @param value value to be set.
  33405. * @returns this effect.
  33406. */
  33407. setFloat(uniformName: string, value: number): Effect;
  33408. /**
  33409. * Sets a boolean on a uniform variable.
  33410. * @param uniformName Name of the variable.
  33411. * @param bool value to be set.
  33412. * @returns this effect.
  33413. */
  33414. setBool(uniformName: string, bool: boolean): Effect;
  33415. /**
  33416. * Sets a Vector2 on a uniform variable.
  33417. * @param uniformName Name of the variable.
  33418. * @param vector2 vector2 to be set.
  33419. * @returns this effect.
  33420. */
  33421. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  33422. /**
  33423. * Sets a float2 on a uniform variable.
  33424. * @param uniformName Name of the variable.
  33425. * @param x First float in float2.
  33426. * @param y Second float in float2.
  33427. * @returns this effect.
  33428. */
  33429. setFloat2(uniformName: string, x: number, y: number): Effect;
  33430. /**
  33431. * Sets a Vector3 on a uniform variable.
  33432. * @param uniformName Name of the variable.
  33433. * @param vector3 Value to be set.
  33434. * @returns this effect.
  33435. */
  33436. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  33437. /**
  33438. * Sets a float3 on a uniform variable.
  33439. * @param uniformName Name of the variable.
  33440. * @param x First float in float3.
  33441. * @param y Second float in float3.
  33442. * @param z Third float in float3.
  33443. * @returns this effect.
  33444. */
  33445. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  33446. /**
  33447. * Sets a Vector4 on a uniform variable.
  33448. * @param uniformName Name of the variable.
  33449. * @param vector4 Value to be set.
  33450. * @returns this effect.
  33451. */
  33452. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  33453. /**
  33454. * Sets a float4 on a uniform variable.
  33455. * @param uniformName Name of the variable.
  33456. * @param x First float in float4.
  33457. * @param y Second float in float4.
  33458. * @param z Third float in float4.
  33459. * @param w Fourth float in float4.
  33460. * @returns this effect.
  33461. */
  33462. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  33463. /**
  33464. * Sets a Color3 on a uniform variable.
  33465. * @param uniformName Name of the variable.
  33466. * @param color3 Value to be set.
  33467. * @returns this effect.
  33468. */
  33469. setColor3(uniformName: string, color3: IColor3Like): Effect;
  33470. /**
  33471. * Sets a Color4 on a uniform variable.
  33472. * @param uniformName Name of the variable.
  33473. * @param color3 Value to be set.
  33474. * @param alpha Alpha value to be set.
  33475. * @returns this effect.
  33476. */
  33477. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  33478. /**
  33479. * Sets a Color4 on a uniform variable
  33480. * @param uniformName defines the name of the variable
  33481. * @param color4 defines the value to be set
  33482. * @returns this effect.
  33483. */
  33484. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  33485. /** Release all associated resources */
  33486. dispose(): void;
  33487. /**
  33488. * This function will add a new shader to the shader store
  33489. * @param name the name of the shader
  33490. * @param pixelShader optional pixel shader content
  33491. * @param vertexShader optional vertex shader content
  33492. */
  33493. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  33494. /**
  33495. * Store of each shader (The can be looked up using effect.key)
  33496. */
  33497. static ShadersStore: {
  33498. [key: string]: string;
  33499. };
  33500. /**
  33501. * Store of each included file for a shader (The can be looked up using effect.key)
  33502. */
  33503. static IncludesShadersStore: {
  33504. [key: string]: string;
  33505. };
  33506. /**
  33507. * Resets the cache of effects.
  33508. */
  33509. static ResetCache(): void;
  33510. }
  33511. }
  33512. declare module BABYLON {
  33513. /**
  33514. * Interface used to describe the capabilities of the engine relatively to the current browser
  33515. */
  33516. export interface EngineCapabilities {
  33517. /** Maximum textures units per fragment shader */
  33518. maxTexturesImageUnits: number;
  33519. /** Maximum texture units per vertex shader */
  33520. maxVertexTextureImageUnits: number;
  33521. /** Maximum textures units in the entire pipeline */
  33522. maxCombinedTexturesImageUnits: number;
  33523. /** Maximum texture size */
  33524. maxTextureSize: number;
  33525. /** Maximum texture samples */
  33526. maxSamples?: number;
  33527. /** Maximum cube texture size */
  33528. maxCubemapTextureSize: number;
  33529. /** Maximum render texture size */
  33530. maxRenderTextureSize: number;
  33531. /** Maximum number of vertex attributes */
  33532. maxVertexAttribs: number;
  33533. /** Maximum number of varyings */
  33534. maxVaryingVectors: number;
  33535. /** Maximum number of uniforms per vertex shader */
  33536. maxVertexUniformVectors: number;
  33537. /** Maximum number of uniforms per fragment shader */
  33538. maxFragmentUniformVectors: number;
  33539. /** Defines if standard derivates (dx/dy) are supported */
  33540. standardDerivatives: boolean;
  33541. /** Defines if s3tc texture compression is supported */
  33542. s3tc?: WEBGL_compressed_texture_s3tc;
  33543. /** Defines if pvrtc texture compression is supported */
  33544. pvrtc: any;
  33545. /** Defines if etc1 texture compression is supported */
  33546. etc1: any;
  33547. /** Defines if etc2 texture compression is supported */
  33548. etc2: any;
  33549. /** Defines if astc texture compression is supported */
  33550. astc: any;
  33551. /** Defines if float textures are supported */
  33552. textureFloat: boolean;
  33553. /** Defines if vertex array objects are supported */
  33554. vertexArrayObject: boolean;
  33555. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  33556. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  33557. /** Gets the maximum level of anisotropy supported */
  33558. maxAnisotropy: number;
  33559. /** Defines if instancing is supported */
  33560. instancedArrays: boolean;
  33561. /** Defines if 32 bits indices are supported */
  33562. uintIndices: boolean;
  33563. /** Defines if high precision shaders are supported */
  33564. highPrecisionShaderSupported: boolean;
  33565. /** Defines if depth reading in the fragment shader is supported */
  33566. fragmentDepthSupported: boolean;
  33567. /** Defines if float texture linear filtering is supported*/
  33568. textureFloatLinearFiltering: boolean;
  33569. /** Defines if rendering to float textures is supported */
  33570. textureFloatRender: boolean;
  33571. /** Defines if half float textures are supported*/
  33572. textureHalfFloat: boolean;
  33573. /** Defines if half float texture linear filtering is supported*/
  33574. textureHalfFloatLinearFiltering: boolean;
  33575. /** Defines if rendering to half float textures is supported */
  33576. textureHalfFloatRender: boolean;
  33577. /** Defines if textureLOD shader command is supported */
  33578. textureLOD: boolean;
  33579. /** Defines if draw buffers extension is supported */
  33580. drawBuffersExtension: boolean;
  33581. /** Defines if depth textures are supported */
  33582. depthTextureExtension: boolean;
  33583. /** Defines if float color buffer are supported */
  33584. colorBufferFloat: boolean;
  33585. /** Gets disjoint timer query extension (null if not supported) */
  33586. timerQuery?: EXT_disjoint_timer_query;
  33587. /** Defines if timestamp can be used with timer query */
  33588. canUseTimestampForTimerQuery: boolean;
  33589. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  33590. multiview?: any;
  33591. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  33592. oculusMultiview?: any;
  33593. /** Function used to let the system compiles shaders in background */
  33594. parallelShaderCompile?: {
  33595. COMPLETION_STATUS_KHR: number;
  33596. };
  33597. /** Max number of texture samples for MSAA */
  33598. maxMSAASamples: number;
  33599. /** Defines if the blend min max extension is supported */
  33600. blendMinMax: boolean;
  33601. }
  33602. }
  33603. declare module BABYLON {
  33604. /**
  33605. * @hidden
  33606. **/
  33607. export class DepthCullingState {
  33608. private _isDepthTestDirty;
  33609. private _isDepthMaskDirty;
  33610. private _isDepthFuncDirty;
  33611. private _isCullFaceDirty;
  33612. private _isCullDirty;
  33613. private _isZOffsetDirty;
  33614. private _isFrontFaceDirty;
  33615. private _depthTest;
  33616. private _depthMask;
  33617. private _depthFunc;
  33618. private _cull;
  33619. private _cullFace;
  33620. private _zOffset;
  33621. private _frontFace;
  33622. /**
  33623. * Initializes the state.
  33624. */
  33625. constructor();
  33626. get isDirty(): boolean;
  33627. get zOffset(): number;
  33628. set zOffset(value: number);
  33629. get cullFace(): Nullable<number>;
  33630. set cullFace(value: Nullable<number>);
  33631. get cull(): Nullable<boolean>;
  33632. set cull(value: Nullable<boolean>);
  33633. get depthFunc(): Nullable<number>;
  33634. set depthFunc(value: Nullable<number>);
  33635. get depthMask(): boolean;
  33636. set depthMask(value: boolean);
  33637. get depthTest(): boolean;
  33638. set depthTest(value: boolean);
  33639. get frontFace(): Nullable<number>;
  33640. set frontFace(value: Nullable<number>);
  33641. reset(): void;
  33642. apply(gl: WebGLRenderingContext): void;
  33643. }
  33644. }
  33645. declare module BABYLON {
  33646. /**
  33647. * @hidden
  33648. **/
  33649. export class StencilState {
  33650. /** 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 */
  33651. static readonly ALWAYS: number;
  33652. /** Passed to stencilOperation to specify that stencil value must be kept */
  33653. static readonly KEEP: number;
  33654. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33655. static readonly REPLACE: number;
  33656. private _isStencilTestDirty;
  33657. private _isStencilMaskDirty;
  33658. private _isStencilFuncDirty;
  33659. private _isStencilOpDirty;
  33660. private _stencilTest;
  33661. private _stencilMask;
  33662. private _stencilFunc;
  33663. private _stencilFuncRef;
  33664. private _stencilFuncMask;
  33665. private _stencilOpStencilFail;
  33666. private _stencilOpDepthFail;
  33667. private _stencilOpStencilDepthPass;
  33668. get isDirty(): boolean;
  33669. get stencilFunc(): number;
  33670. set stencilFunc(value: number);
  33671. get stencilFuncRef(): number;
  33672. set stencilFuncRef(value: number);
  33673. get stencilFuncMask(): number;
  33674. set stencilFuncMask(value: number);
  33675. get stencilOpStencilFail(): number;
  33676. set stencilOpStencilFail(value: number);
  33677. get stencilOpDepthFail(): number;
  33678. set stencilOpDepthFail(value: number);
  33679. get stencilOpStencilDepthPass(): number;
  33680. set stencilOpStencilDepthPass(value: number);
  33681. get stencilMask(): number;
  33682. set stencilMask(value: number);
  33683. get stencilTest(): boolean;
  33684. set stencilTest(value: boolean);
  33685. constructor();
  33686. reset(): void;
  33687. apply(gl: WebGLRenderingContext): void;
  33688. }
  33689. }
  33690. declare module BABYLON {
  33691. /**
  33692. * @hidden
  33693. **/
  33694. export class AlphaState {
  33695. private _isAlphaBlendDirty;
  33696. private _isBlendFunctionParametersDirty;
  33697. private _isBlendEquationParametersDirty;
  33698. private _isBlendConstantsDirty;
  33699. private _alphaBlend;
  33700. private _blendFunctionParameters;
  33701. private _blendEquationParameters;
  33702. private _blendConstants;
  33703. /**
  33704. * Initializes the state.
  33705. */
  33706. constructor();
  33707. get isDirty(): boolean;
  33708. get alphaBlend(): boolean;
  33709. set alphaBlend(value: boolean);
  33710. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  33711. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  33712. setAlphaEquationParameters(rgb: number, alpha: number): void;
  33713. reset(): void;
  33714. apply(gl: WebGLRenderingContext): void;
  33715. }
  33716. }
  33717. declare module BABYLON {
  33718. /** @hidden */
  33719. export class WebGL2ShaderProcessor implements IShaderProcessor {
  33720. attributeProcessor(attribute: string): string;
  33721. varyingProcessor(varying: string, isFragment: boolean): string;
  33722. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  33723. }
  33724. }
  33725. declare module BABYLON {
  33726. /**
  33727. * Interface for attribute information associated with buffer instanciation
  33728. */
  33729. export interface InstancingAttributeInfo {
  33730. /**
  33731. * Name of the GLSL attribute
  33732. * if attribute index is not specified, this is used to retrieve the index from the effect
  33733. */
  33734. attributeName: string;
  33735. /**
  33736. * Index/offset of the attribute in the vertex shader
  33737. * if not specified, this will be computes from the name.
  33738. */
  33739. index?: number;
  33740. /**
  33741. * size of the attribute, 1, 2, 3 or 4
  33742. */
  33743. attributeSize: number;
  33744. /**
  33745. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  33746. */
  33747. offset: number;
  33748. /**
  33749. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  33750. * default to 1
  33751. */
  33752. divisor?: number;
  33753. /**
  33754. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  33755. * default is FLOAT
  33756. */
  33757. attributeType?: number;
  33758. /**
  33759. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  33760. */
  33761. normalized?: boolean;
  33762. }
  33763. }
  33764. declare module BABYLON {
  33765. interface ThinEngine {
  33766. /**
  33767. * Update a video texture
  33768. * @param texture defines the texture to update
  33769. * @param video defines the video element to use
  33770. * @param invertY defines if data must be stored with Y axis inverted
  33771. */
  33772. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  33773. }
  33774. }
  33775. declare module BABYLON {
  33776. /**
  33777. * Settings for finer control over video usage
  33778. */
  33779. export interface VideoTextureSettings {
  33780. /**
  33781. * Applies `autoplay` to video, if specified
  33782. */
  33783. autoPlay?: boolean;
  33784. /**
  33785. * Applies `loop` to video, if specified
  33786. */
  33787. loop?: boolean;
  33788. /**
  33789. * Automatically updates internal texture from video at every frame in the render loop
  33790. */
  33791. autoUpdateTexture: boolean;
  33792. /**
  33793. * Image src displayed during the video loading or until the user interacts with the video.
  33794. */
  33795. poster?: string;
  33796. }
  33797. /**
  33798. * If you want to display a video in your scene, this is the special texture for that.
  33799. * This special texture works similar to other textures, with the exception of a few parameters.
  33800. * @see https://doc.babylonjs.com/how_to/video_texture
  33801. */
  33802. export class VideoTexture extends Texture {
  33803. /**
  33804. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  33805. */
  33806. readonly autoUpdateTexture: boolean;
  33807. /**
  33808. * The video instance used by the texture internally
  33809. */
  33810. readonly video: HTMLVideoElement;
  33811. private _onUserActionRequestedObservable;
  33812. /**
  33813. * Event triggerd when a dom action is required by the user to play the video.
  33814. * This happens due to recent changes in browser policies preventing video to auto start.
  33815. */
  33816. get onUserActionRequestedObservable(): Observable<Texture>;
  33817. private _generateMipMaps;
  33818. private _stillImageCaptured;
  33819. private _displayingPosterTexture;
  33820. private _settings;
  33821. private _createInternalTextureOnEvent;
  33822. private _frameId;
  33823. private _currentSrc;
  33824. /**
  33825. * Creates a video texture.
  33826. * If you want to display a video in your scene, this is the special texture for that.
  33827. * This special texture works similar to other textures, with the exception of a few parameters.
  33828. * @see https://doc.babylonjs.com/how_to/video_texture
  33829. * @param name optional name, will detect from video source, if not defined
  33830. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  33831. * @param scene is obviously the current scene.
  33832. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  33833. * @param invertY is false by default but can be used to invert video on Y axis
  33834. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  33835. * @param settings allows finer control over video usage
  33836. */
  33837. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  33838. private _getName;
  33839. private _getVideo;
  33840. private _createInternalTexture;
  33841. private reset;
  33842. /**
  33843. * @hidden Internal method to initiate `update`.
  33844. */
  33845. _rebuild(): void;
  33846. /**
  33847. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  33848. */
  33849. update(): void;
  33850. /**
  33851. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  33852. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  33853. */
  33854. updateTexture(isVisible: boolean): void;
  33855. protected _updateInternalTexture: () => void;
  33856. /**
  33857. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  33858. * @param url New url.
  33859. */
  33860. updateURL(url: string): void;
  33861. /**
  33862. * Clones the texture.
  33863. * @returns the cloned texture
  33864. */
  33865. clone(): VideoTexture;
  33866. /**
  33867. * Dispose the texture and release its associated resources.
  33868. */
  33869. dispose(): void;
  33870. /**
  33871. * Creates a video texture straight from a stream.
  33872. * @param scene Define the scene the texture should be created in
  33873. * @param stream Define the stream the texture should be created from
  33874. * @returns The created video texture as a promise
  33875. */
  33876. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  33877. /**
  33878. * Creates a video texture straight from your WebCam video feed.
  33879. * @param scene Define the scene the texture should be created in
  33880. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  33881. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  33882. * @returns The created video texture as a promise
  33883. */
  33884. static CreateFromWebCamAsync(scene: Scene, constraints: {
  33885. minWidth: number;
  33886. maxWidth: number;
  33887. minHeight: number;
  33888. maxHeight: number;
  33889. deviceId: string;
  33890. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  33891. /**
  33892. * Creates a video texture straight from your WebCam video feed.
  33893. * @param scene Define the scene the texture should be created in
  33894. * @param onReady Define a callback to triggered once the texture will be ready
  33895. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  33896. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  33897. */
  33898. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  33899. minWidth: number;
  33900. maxWidth: number;
  33901. minHeight: number;
  33902. maxHeight: number;
  33903. deviceId: string;
  33904. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  33905. }
  33906. }
  33907. declare module BABYLON {
  33908. /**
  33909. * Defines the interface used by objects working like Scene
  33910. * @hidden
  33911. */
  33912. export interface ISceneLike {
  33913. _addPendingData(data: any): void;
  33914. _removePendingData(data: any): void;
  33915. offlineProvider: IOfflineProvider;
  33916. }
  33917. /** Interface defining initialization parameters for Engine class */
  33918. export interface EngineOptions extends WebGLContextAttributes {
  33919. /**
  33920. * Defines if the engine should no exceed a specified device ratio
  33921. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  33922. */
  33923. limitDeviceRatio?: number;
  33924. /**
  33925. * Defines if webvr should be enabled automatically
  33926. * @see http://doc.babylonjs.com/how_to/webvr_camera
  33927. */
  33928. autoEnableWebVR?: boolean;
  33929. /**
  33930. * Defines if webgl2 should be turned off even if supported
  33931. * @see http://doc.babylonjs.com/features/webgl2
  33932. */
  33933. disableWebGL2Support?: boolean;
  33934. /**
  33935. * Defines if webaudio should be initialized as well
  33936. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33937. */
  33938. audioEngine?: boolean;
  33939. /**
  33940. * Defines if animations should run using a deterministic lock step
  33941. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33942. */
  33943. deterministicLockstep?: boolean;
  33944. /** Defines the maximum steps to use with deterministic lock step mode */
  33945. lockstepMaxSteps?: number;
  33946. /** Defines the seconds between each deterministic lock step */
  33947. timeStep?: number;
  33948. /**
  33949. * Defines that engine should ignore context lost events
  33950. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  33951. */
  33952. doNotHandleContextLost?: boolean;
  33953. /**
  33954. * Defines that engine should ignore modifying touch action attribute and style
  33955. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  33956. */
  33957. doNotHandleTouchAction?: boolean;
  33958. /**
  33959. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  33960. */
  33961. useHighPrecisionFloats?: boolean;
  33962. }
  33963. /**
  33964. * The base engine class (root of all engines)
  33965. */
  33966. export class ThinEngine {
  33967. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  33968. static ExceptionList: ({
  33969. key: string;
  33970. capture: string;
  33971. captureConstraint: number;
  33972. targets: string[];
  33973. } | {
  33974. key: string;
  33975. capture: null;
  33976. captureConstraint: null;
  33977. targets: string[];
  33978. })[];
  33979. /** @hidden */
  33980. static _TextureLoaders: IInternalTextureLoader[];
  33981. /**
  33982. * Returns the current npm package of the sdk
  33983. */
  33984. static get NpmPackage(): string;
  33985. /**
  33986. * Returns the current version of the framework
  33987. */
  33988. static get Version(): string;
  33989. /**
  33990. * Returns a string describing the current engine
  33991. */
  33992. get description(): string;
  33993. /**
  33994. * Gets or sets the epsilon value used by collision engine
  33995. */
  33996. static CollisionsEpsilon: number;
  33997. /**
  33998. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  33999. */
  34000. static get ShadersRepository(): string;
  34001. static set ShadersRepository(value: string);
  34002. /** @hidden */
  34003. _shaderProcessor: IShaderProcessor;
  34004. /**
  34005. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  34006. */
  34007. forcePOTTextures: boolean;
  34008. /**
  34009. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  34010. */
  34011. isFullscreen: boolean;
  34012. /**
  34013. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  34014. */
  34015. cullBackFaces: boolean;
  34016. /**
  34017. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  34018. */
  34019. renderEvenInBackground: boolean;
  34020. /**
  34021. * Gets or sets a boolean indicating that cache can be kept between frames
  34022. */
  34023. preventCacheWipeBetweenFrames: boolean;
  34024. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  34025. validateShaderPrograms: boolean;
  34026. /**
  34027. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  34028. * This can provide greater z depth for distant objects.
  34029. */
  34030. useReverseDepthBuffer: boolean;
  34031. /**
  34032. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  34033. */
  34034. disableUniformBuffers: boolean;
  34035. /** @hidden */
  34036. _uniformBuffers: UniformBuffer[];
  34037. /**
  34038. * Gets a boolean indicating that the engine supports uniform buffers
  34039. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  34040. */
  34041. get supportsUniformBuffers(): boolean;
  34042. /** @hidden */
  34043. _gl: WebGLRenderingContext;
  34044. /** @hidden */
  34045. _webGLVersion: number;
  34046. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  34047. protected _windowIsBackground: boolean;
  34048. protected _creationOptions: EngineOptions;
  34049. protected _highPrecisionShadersAllowed: boolean;
  34050. /** @hidden */
  34051. get _shouldUseHighPrecisionShader(): boolean;
  34052. /**
  34053. * Gets a boolean indicating that only power of 2 textures are supported
  34054. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  34055. */
  34056. get needPOTTextures(): boolean;
  34057. /** @hidden */
  34058. _badOS: boolean;
  34059. /** @hidden */
  34060. _badDesktopOS: boolean;
  34061. private _hardwareScalingLevel;
  34062. /** @hidden */
  34063. _caps: EngineCapabilities;
  34064. private _isStencilEnable;
  34065. private _glVersion;
  34066. private _glRenderer;
  34067. private _glVendor;
  34068. /** @hidden */
  34069. _videoTextureSupported: boolean;
  34070. protected _renderingQueueLaunched: boolean;
  34071. protected _activeRenderLoops: (() => void)[];
  34072. /**
  34073. * Observable signaled when a context lost event is raised
  34074. */
  34075. onContextLostObservable: Observable<ThinEngine>;
  34076. /**
  34077. * Observable signaled when a context restored event is raised
  34078. */
  34079. onContextRestoredObservable: Observable<ThinEngine>;
  34080. private _onContextLost;
  34081. private _onContextRestored;
  34082. protected _contextWasLost: boolean;
  34083. /** @hidden */
  34084. _doNotHandleContextLost: boolean;
  34085. /**
  34086. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  34087. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  34088. */
  34089. get doNotHandleContextLost(): boolean;
  34090. set doNotHandleContextLost(value: boolean);
  34091. /**
  34092. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  34093. */
  34094. disableVertexArrayObjects: boolean;
  34095. /** @hidden */
  34096. protected _colorWrite: boolean;
  34097. /** @hidden */
  34098. protected _colorWriteChanged: boolean;
  34099. /** @hidden */
  34100. protected _depthCullingState: DepthCullingState;
  34101. /** @hidden */
  34102. protected _stencilState: StencilState;
  34103. /** @hidden */
  34104. _alphaState: AlphaState;
  34105. /** @hidden */
  34106. _alphaMode: number;
  34107. /** @hidden */
  34108. _alphaEquation: number;
  34109. /** @hidden */
  34110. _internalTexturesCache: InternalTexture[];
  34111. /** @hidden */
  34112. protected _activeChannel: number;
  34113. private _currentTextureChannel;
  34114. /** @hidden */
  34115. protected _boundTexturesCache: {
  34116. [key: string]: Nullable<InternalTexture>;
  34117. };
  34118. /** @hidden */
  34119. protected _currentEffect: Nullable<Effect>;
  34120. /** @hidden */
  34121. protected _currentProgram: Nullable<WebGLProgram>;
  34122. private _compiledEffects;
  34123. private _vertexAttribArraysEnabled;
  34124. /** @hidden */
  34125. protected _cachedViewport: Nullable<IViewportLike>;
  34126. private _cachedVertexArrayObject;
  34127. /** @hidden */
  34128. protected _cachedVertexBuffers: any;
  34129. /** @hidden */
  34130. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  34131. /** @hidden */
  34132. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  34133. /** @hidden */
  34134. _currentRenderTarget: Nullable<InternalTexture>;
  34135. private _uintIndicesCurrentlySet;
  34136. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  34137. /** @hidden */
  34138. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  34139. /** @hidden */
  34140. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  34141. private _currentBufferPointers;
  34142. private _currentInstanceLocations;
  34143. private _currentInstanceBuffers;
  34144. private _textureUnits;
  34145. /** @hidden */
  34146. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  34147. /** @hidden */
  34148. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  34149. /** @hidden */
  34150. _boundRenderFunction: any;
  34151. private _vaoRecordInProgress;
  34152. private _mustWipeVertexAttributes;
  34153. private _emptyTexture;
  34154. private _emptyCubeTexture;
  34155. private _emptyTexture3D;
  34156. private _emptyTexture2DArray;
  34157. /** @hidden */
  34158. _frameHandler: number;
  34159. private _nextFreeTextureSlots;
  34160. private _maxSimultaneousTextures;
  34161. private _activeRequests;
  34162. /** @hidden */
  34163. _transformTextureUrl: Nullable<(url: string) => string>;
  34164. protected get _supportsHardwareTextureRescaling(): boolean;
  34165. private _framebufferDimensionsObject;
  34166. /**
  34167. * sets the object from which width and height will be taken from when getting render width and height
  34168. * Will fallback to the gl object
  34169. * @param dimensions the framebuffer width and height that will be used.
  34170. */
  34171. set framebufferDimensionsObject(dimensions: Nullable<{
  34172. framebufferWidth: number;
  34173. framebufferHeight: number;
  34174. }>);
  34175. /**
  34176. * Gets the current viewport
  34177. */
  34178. get currentViewport(): Nullable<IViewportLike>;
  34179. /**
  34180. * Gets the default empty texture
  34181. */
  34182. get emptyTexture(): InternalTexture;
  34183. /**
  34184. * Gets the default empty 3D texture
  34185. */
  34186. get emptyTexture3D(): InternalTexture;
  34187. /**
  34188. * Gets the default empty 2D array texture
  34189. */
  34190. get emptyTexture2DArray(): InternalTexture;
  34191. /**
  34192. * Gets the default empty cube texture
  34193. */
  34194. get emptyCubeTexture(): InternalTexture;
  34195. /**
  34196. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  34197. */
  34198. readonly premultipliedAlpha: boolean;
  34199. /**
  34200. * Observable event triggered before each texture is initialized
  34201. */
  34202. onBeforeTextureInitObservable: Observable<Texture>;
  34203. /**
  34204. * Creates a new engine
  34205. * @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
  34206. * @param antialias defines enable antialiasing (default: false)
  34207. * @param options defines further options to be sent to the getContext() function
  34208. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34209. */
  34210. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34211. private _rebuildInternalTextures;
  34212. private _rebuildEffects;
  34213. /**
  34214. * Gets a boolean indicating if all created effects are ready
  34215. * @returns true if all effects are ready
  34216. */
  34217. areAllEffectsReady(): boolean;
  34218. protected _rebuildBuffers(): void;
  34219. protected _initGLContext(): void;
  34220. /**
  34221. * Gets version of the current webGL context
  34222. */
  34223. get webGLVersion(): number;
  34224. /**
  34225. * Gets a string idenfifying the name of the class
  34226. * @returns "Engine" string
  34227. */
  34228. getClassName(): string;
  34229. /**
  34230. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  34231. */
  34232. get isStencilEnable(): boolean;
  34233. /** @hidden */
  34234. _prepareWorkingCanvas(): void;
  34235. /**
  34236. * Reset the texture cache to empty state
  34237. */
  34238. resetTextureCache(): void;
  34239. /**
  34240. * Gets an object containing information about the current webGL context
  34241. * @returns an object containing the vender, the renderer and the version of the current webGL context
  34242. */
  34243. getGlInfo(): {
  34244. vendor: string;
  34245. renderer: string;
  34246. version: string;
  34247. };
  34248. /**
  34249. * Defines the hardware scaling level.
  34250. * By default the hardware scaling level is computed from the window device ratio.
  34251. * 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.
  34252. * @param level defines the level to use
  34253. */
  34254. setHardwareScalingLevel(level: number): void;
  34255. /**
  34256. * Gets the current hardware scaling level.
  34257. * By default the hardware scaling level is computed from the window device ratio.
  34258. * 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.
  34259. * @returns a number indicating the current hardware scaling level
  34260. */
  34261. getHardwareScalingLevel(): number;
  34262. /**
  34263. * Gets the list of loaded textures
  34264. * @returns an array containing all loaded textures
  34265. */
  34266. getLoadedTexturesCache(): InternalTexture[];
  34267. /**
  34268. * Gets the object containing all engine capabilities
  34269. * @returns the EngineCapabilities object
  34270. */
  34271. getCaps(): EngineCapabilities;
  34272. /**
  34273. * stop executing a render loop function and remove it from the execution array
  34274. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  34275. */
  34276. stopRenderLoop(renderFunction?: () => void): void;
  34277. /** @hidden */
  34278. _renderLoop(): void;
  34279. /**
  34280. * Gets the HTML canvas attached with the current webGL context
  34281. * @returns a HTML canvas
  34282. */
  34283. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  34284. /**
  34285. * Gets host window
  34286. * @returns the host window object
  34287. */
  34288. getHostWindow(): Nullable<Window>;
  34289. /**
  34290. * Gets the current render width
  34291. * @param useScreen defines if screen size must be used (or the current render target if any)
  34292. * @returns a number defining the current render width
  34293. */
  34294. getRenderWidth(useScreen?: boolean): number;
  34295. /**
  34296. * Gets the current render height
  34297. * @param useScreen defines if screen size must be used (or the current render target if any)
  34298. * @returns a number defining the current render height
  34299. */
  34300. getRenderHeight(useScreen?: boolean): number;
  34301. /**
  34302. * Can be used to override the current requestAnimationFrame requester.
  34303. * @hidden
  34304. */
  34305. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  34306. /**
  34307. * Register and execute a render loop. The engine can have more than one render function
  34308. * @param renderFunction defines the function to continuously execute
  34309. */
  34310. runRenderLoop(renderFunction: () => void): void;
  34311. /**
  34312. * Clear the current render buffer or the current render target (if any is set up)
  34313. * @param color defines the color to use
  34314. * @param backBuffer defines if the back buffer must be cleared
  34315. * @param depth defines if the depth buffer must be cleared
  34316. * @param stencil defines if the stencil buffer must be cleared
  34317. */
  34318. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  34319. private _viewportCached;
  34320. /** @hidden */
  34321. _viewport(x: number, y: number, width: number, height: number): void;
  34322. /**
  34323. * Set the WebGL's viewport
  34324. * @param viewport defines the viewport element to be used
  34325. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  34326. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  34327. */
  34328. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  34329. /**
  34330. * Begin a new frame
  34331. */
  34332. beginFrame(): void;
  34333. /**
  34334. * Enf the current frame
  34335. */
  34336. endFrame(): void;
  34337. /**
  34338. * Resize the view according to the canvas' size
  34339. */
  34340. resize(): void;
  34341. /**
  34342. * Force a specific size of the canvas
  34343. * @param width defines the new canvas' width
  34344. * @param height defines the new canvas' height
  34345. */
  34346. setSize(width: number, height: number): void;
  34347. /**
  34348. * Binds the frame buffer to the specified texture.
  34349. * @param texture The texture to render to or null for the default canvas
  34350. * @param faceIndex The face of the texture to render to in case of cube texture
  34351. * @param requiredWidth The width of the target to render to
  34352. * @param requiredHeight The height of the target to render to
  34353. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  34354. * @param lodLevel defines the lod level to bind to the frame buffer
  34355. * @param layer defines the 2d array index to bind to frame buffer to
  34356. */
  34357. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  34358. /** @hidden */
  34359. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  34360. /**
  34361. * Unbind the current render target texture from the webGL context
  34362. * @param texture defines the render target texture to unbind
  34363. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  34364. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  34365. */
  34366. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  34367. /**
  34368. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  34369. */
  34370. flushFramebuffer(): void;
  34371. /**
  34372. * Unbind the current render target and bind the default framebuffer
  34373. */
  34374. restoreDefaultFramebuffer(): void;
  34375. /** @hidden */
  34376. protected _resetVertexBufferBinding(): void;
  34377. /**
  34378. * Creates a vertex buffer
  34379. * @param data the data for the vertex buffer
  34380. * @returns the new WebGL static buffer
  34381. */
  34382. createVertexBuffer(data: DataArray): DataBuffer;
  34383. private _createVertexBuffer;
  34384. /**
  34385. * Creates a dynamic vertex buffer
  34386. * @param data the data for the dynamic vertex buffer
  34387. * @returns the new WebGL dynamic buffer
  34388. */
  34389. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  34390. protected _resetIndexBufferBinding(): void;
  34391. /**
  34392. * Creates a new index buffer
  34393. * @param indices defines the content of the index buffer
  34394. * @param updatable defines if the index buffer must be updatable
  34395. * @returns a new webGL buffer
  34396. */
  34397. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  34398. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  34399. /**
  34400. * Bind a webGL buffer to the webGL context
  34401. * @param buffer defines the buffer to bind
  34402. */
  34403. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  34404. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  34405. private bindBuffer;
  34406. /**
  34407. * update the bound buffer with the given data
  34408. * @param data defines the data to update
  34409. */
  34410. updateArrayBuffer(data: Float32Array): void;
  34411. private _vertexAttribPointer;
  34412. /** @hidden */
  34413. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  34414. private _bindVertexBuffersAttributes;
  34415. /**
  34416. * Records a vertex array object
  34417. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34418. * @param vertexBuffers defines the list of vertex buffers to store
  34419. * @param indexBuffer defines the index buffer to store
  34420. * @param effect defines the effect to store
  34421. * @returns the new vertex array object
  34422. */
  34423. recordVertexArrayObject(vertexBuffers: {
  34424. [key: string]: VertexBuffer;
  34425. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  34426. /**
  34427. * Bind a specific vertex array object
  34428. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34429. * @param vertexArrayObject defines the vertex array object to bind
  34430. * @param indexBuffer defines the index buffer to bind
  34431. */
  34432. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  34433. /**
  34434. * Bind webGl buffers directly to the webGL context
  34435. * @param vertexBuffer defines the vertex buffer to bind
  34436. * @param indexBuffer defines the index buffer to bind
  34437. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  34438. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  34439. * @param effect defines the effect associated with the vertex buffer
  34440. */
  34441. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  34442. private _unbindVertexArrayObject;
  34443. /**
  34444. * Bind a list of vertex buffers to the webGL context
  34445. * @param vertexBuffers defines the list of vertex buffers to bind
  34446. * @param indexBuffer defines the index buffer to bind
  34447. * @param effect defines the effect associated with the vertex buffers
  34448. */
  34449. bindBuffers(vertexBuffers: {
  34450. [key: string]: Nullable<VertexBuffer>;
  34451. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  34452. /**
  34453. * Unbind all instance attributes
  34454. */
  34455. unbindInstanceAttributes(): void;
  34456. /**
  34457. * Release and free the memory of a vertex array object
  34458. * @param vao defines the vertex array object to delete
  34459. */
  34460. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  34461. /** @hidden */
  34462. _releaseBuffer(buffer: DataBuffer): boolean;
  34463. protected _deleteBuffer(buffer: DataBuffer): void;
  34464. /**
  34465. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  34466. * @param instancesBuffer defines the webGL buffer to update and bind
  34467. * @param data defines the data to store in the buffer
  34468. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  34469. */
  34470. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  34471. /**
  34472. * Bind the content of a webGL buffer used with instantiation
  34473. * @param instancesBuffer defines the webGL buffer to bind
  34474. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  34475. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  34476. */
  34477. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  34478. /**
  34479. * Disable the instance attribute corresponding to the name in parameter
  34480. * @param name defines the name of the attribute to disable
  34481. */
  34482. disableInstanceAttributeByName(name: string): void;
  34483. /**
  34484. * Disable the instance attribute corresponding to the location in parameter
  34485. * @param attributeLocation defines the attribute location of the attribute to disable
  34486. */
  34487. disableInstanceAttribute(attributeLocation: number): void;
  34488. /**
  34489. * Disable the attribute corresponding to the location in parameter
  34490. * @param attributeLocation defines the attribute location of the attribute to disable
  34491. */
  34492. disableAttributeByIndex(attributeLocation: number): void;
  34493. /**
  34494. * Send a draw order
  34495. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34496. * @param indexStart defines the starting index
  34497. * @param indexCount defines the number of index to draw
  34498. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34499. */
  34500. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  34501. /**
  34502. * Draw a list of points
  34503. * @param verticesStart defines the index of first vertex to draw
  34504. * @param verticesCount defines the count of vertices to draw
  34505. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34506. */
  34507. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34508. /**
  34509. * Draw a list of unindexed primitives
  34510. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34511. * @param verticesStart defines the index of first vertex to draw
  34512. * @param verticesCount defines the count of vertices to draw
  34513. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34514. */
  34515. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34516. /**
  34517. * Draw a list of indexed primitives
  34518. * @param fillMode defines the primitive to use
  34519. * @param indexStart defines the starting index
  34520. * @param indexCount defines the number of index to draw
  34521. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34522. */
  34523. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  34524. /**
  34525. * Draw a list of unindexed primitives
  34526. * @param fillMode defines the primitive to use
  34527. * @param verticesStart defines the index of first vertex to draw
  34528. * @param verticesCount defines the count of vertices to draw
  34529. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34530. */
  34531. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34532. private _drawMode;
  34533. /** @hidden */
  34534. protected _reportDrawCall(): void;
  34535. /** @hidden */
  34536. _releaseEffect(effect: Effect): void;
  34537. /** @hidden */
  34538. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34539. /**
  34540. * Create a new effect (used to store vertex/fragment shaders)
  34541. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  34542. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  34543. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  34544. * @param samplers defines an array of string used to represent textures
  34545. * @param defines defines the string containing the defines to use to compile the shaders
  34546. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  34547. * @param onCompiled defines a function to call when the effect creation is successful
  34548. * @param onError defines a function to call when the effect creation has failed
  34549. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  34550. * @returns the new Effect
  34551. */
  34552. 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;
  34553. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  34554. private _compileShader;
  34555. private _compileRawShader;
  34556. /** @hidden */
  34557. _getShaderSource(shader: WebGLShader): Nullable<string>;
  34558. /**
  34559. * Directly creates a webGL program
  34560. * @param pipelineContext defines the pipeline context to attach to
  34561. * @param vertexCode defines the vertex shader code to use
  34562. * @param fragmentCode defines the fragment shader code to use
  34563. * @param context defines the webGL context to use (if not set, the current one will be used)
  34564. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34565. * @returns the new webGL program
  34566. */
  34567. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34568. /**
  34569. * Creates a webGL program
  34570. * @param pipelineContext defines the pipeline context to attach to
  34571. * @param vertexCode defines the vertex shader code to use
  34572. * @param fragmentCode defines the fragment shader code to use
  34573. * @param defines defines the string containing the defines to use to compile the shaders
  34574. * @param context defines the webGL context to use (if not set, the current one will be used)
  34575. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34576. * @returns the new webGL program
  34577. */
  34578. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34579. /**
  34580. * Creates a new pipeline context
  34581. * @returns the new pipeline
  34582. */
  34583. createPipelineContext(): IPipelineContext;
  34584. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34585. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  34586. /** @hidden */
  34587. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  34588. /** @hidden */
  34589. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  34590. /** @hidden */
  34591. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  34592. /**
  34593. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  34594. * @param pipelineContext defines the pipeline context to use
  34595. * @param uniformsNames defines the list of uniform names
  34596. * @returns an array of webGL uniform locations
  34597. */
  34598. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  34599. /**
  34600. * Gets the lsit of active attributes for a given webGL program
  34601. * @param pipelineContext defines the pipeline context to use
  34602. * @param attributesNames defines the list of attribute names to get
  34603. * @returns an array of indices indicating the offset of each attribute
  34604. */
  34605. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  34606. /**
  34607. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  34608. * @param effect defines the effect to activate
  34609. */
  34610. enableEffect(effect: Nullable<Effect>): void;
  34611. /**
  34612. * Set the value of an uniform to a number (int)
  34613. * @param uniform defines the webGL uniform location where to store the value
  34614. * @param value defines the int number to store
  34615. */
  34616. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  34617. /**
  34618. * Set the value of an uniform to an array of int32
  34619. * @param uniform defines the webGL uniform location where to store the value
  34620. * @param array defines the array of int32 to store
  34621. */
  34622. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34623. /**
  34624. * Set the value of an uniform to an array of int32 (stored as vec2)
  34625. * @param uniform defines the webGL uniform location where to store the value
  34626. * @param array defines the array of int32 to store
  34627. */
  34628. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34629. /**
  34630. * Set the value of an uniform to an array of int32 (stored as vec3)
  34631. * @param uniform defines the webGL uniform location where to store the value
  34632. * @param array defines the array of int32 to store
  34633. */
  34634. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34635. /**
  34636. * Set the value of an uniform to an array of int32 (stored as vec4)
  34637. * @param uniform defines the webGL uniform location where to store the value
  34638. * @param array defines the array of int32 to store
  34639. */
  34640. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34641. /**
  34642. * Set the value of an uniform to an array of number
  34643. * @param uniform defines the webGL uniform location where to store the value
  34644. * @param array defines the array of number to store
  34645. */
  34646. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34647. /**
  34648. * Set the value of an uniform to an array of number (stored as vec2)
  34649. * @param uniform defines the webGL uniform location where to store the value
  34650. * @param array defines the array of number to store
  34651. */
  34652. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34653. /**
  34654. * Set the value of an uniform to an array of number (stored as vec3)
  34655. * @param uniform defines the webGL uniform location where to store the value
  34656. * @param array defines the array of number to store
  34657. */
  34658. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34659. /**
  34660. * Set the value of an uniform to an array of number (stored as vec4)
  34661. * @param uniform defines the webGL uniform location where to store the value
  34662. * @param array defines the array of number to store
  34663. */
  34664. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34665. /**
  34666. * Set the value of an uniform to an array of float32 (stored as matrices)
  34667. * @param uniform defines the webGL uniform location where to store the value
  34668. * @param matrices defines the array of float32 to store
  34669. */
  34670. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  34671. /**
  34672. * Set the value of an uniform to a matrix (3x3)
  34673. * @param uniform defines the webGL uniform location where to store the value
  34674. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  34675. */
  34676. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  34677. /**
  34678. * Set the value of an uniform to a matrix (2x2)
  34679. * @param uniform defines the webGL uniform location where to store the value
  34680. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  34681. */
  34682. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  34683. /**
  34684. * Set the value of an uniform to a number (float)
  34685. * @param uniform defines the webGL uniform location where to store the value
  34686. * @param value defines the float number to store
  34687. */
  34688. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  34689. /**
  34690. * Set the value of an uniform to a vec2
  34691. * @param uniform defines the webGL uniform location where to store the value
  34692. * @param x defines the 1st component of the value
  34693. * @param y defines the 2nd component of the value
  34694. */
  34695. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  34696. /**
  34697. * Set the value of an uniform to a vec3
  34698. * @param uniform defines the webGL uniform location where to store the value
  34699. * @param x defines the 1st component of the value
  34700. * @param y defines the 2nd component of the value
  34701. * @param z defines the 3rd component of the value
  34702. */
  34703. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  34704. /**
  34705. * Set the value of an uniform to a vec4
  34706. * @param uniform defines the webGL uniform location where to store the value
  34707. * @param x defines the 1st component of the value
  34708. * @param y defines the 2nd component of the value
  34709. * @param z defines the 3rd component of the value
  34710. * @param w defines the 4th component of the value
  34711. */
  34712. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  34713. /**
  34714. * Apply all cached states (depth, culling, stencil and alpha)
  34715. */
  34716. applyStates(): void;
  34717. /**
  34718. * Enable or disable color writing
  34719. * @param enable defines the state to set
  34720. */
  34721. setColorWrite(enable: boolean): void;
  34722. /**
  34723. * Gets a boolean indicating if color writing is enabled
  34724. * @returns the current color writing state
  34725. */
  34726. getColorWrite(): boolean;
  34727. /**
  34728. * Gets the depth culling state manager
  34729. */
  34730. get depthCullingState(): DepthCullingState;
  34731. /**
  34732. * Gets the alpha state manager
  34733. */
  34734. get alphaState(): AlphaState;
  34735. /**
  34736. * Gets the stencil state manager
  34737. */
  34738. get stencilState(): StencilState;
  34739. /**
  34740. * Clears the list of texture accessible through engine.
  34741. * This can help preventing texture load conflict due to name collision.
  34742. */
  34743. clearInternalTexturesCache(): void;
  34744. /**
  34745. * Force the entire cache to be cleared
  34746. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  34747. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  34748. */
  34749. wipeCaches(bruteForce?: boolean): void;
  34750. /** @hidden */
  34751. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  34752. min: number;
  34753. mag: number;
  34754. };
  34755. /** @hidden */
  34756. _createTexture(): WebGLTexture;
  34757. /**
  34758. * Usually called from Texture.ts.
  34759. * Passed information to create a WebGLTexture
  34760. * @param url defines a value which contains one of the following:
  34761. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  34762. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  34763. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  34764. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  34765. * @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)
  34766. * @param scene needed for loading to the correct scene
  34767. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  34768. * @param onLoad optional callback to be called upon successful completion
  34769. * @param onError optional callback to be called upon failure
  34770. * @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
  34771. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  34772. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  34773. * @param forcedExtension defines the extension to use to pick the right loader
  34774. * @param mimeType defines an optional mime type
  34775. * @returns a InternalTexture for assignment back into BABYLON.Texture
  34776. */
  34777. 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;
  34778. /**
  34779. * Loads an image as an HTMLImageElement.
  34780. * @param input url string, ArrayBuffer, or Blob to load
  34781. * @param onLoad callback called when the image successfully loads
  34782. * @param onError callback called when the image fails to load
  34783. * @param offlineProvider offline provider for caching
  34784. * @param mimeType optional mime type
  34785. * @returns the HTMLImageElement of the loaded image
  34786. * @hidden
  34787. */
  34788. 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>;
  34789. /**
  34790. * @hidden
  34791. */
  34792. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34793. private _unpackFlipYCached;
  34794. /**
  34795. * In case you are sharing the context with other applications, it might
  34796. * be interested to not cache the unpack flip y state to ensure a consistent
  34797. * value would be set.
  34798. */
  34799. enableUnpackFlipYCached: boolean;
  34800. /** @hidden */
  34801. _unpackFlipY(value: boolean): void;
  34802. /** @hidden */
  34803. _getUnpackAlignement(): number;
  34804. private _getTextureTarget;
  34805. /**
  34806. * Update the sampling mode of a given texture
  34807. * @param samplingMode defines the required sampling mode
  34808. * @param texture defines the texture to update
  34809. * @param generateMipMaps defines whether to generate mipmaps for the texture
  34810. */
  34811. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  34812. /**
  34813. * Update the sampling mode of a given texture
  34814. * @param texture defines the texture to update
  34815. * @param wrapU defines the texture wrap mode of the u coordinates
  34816. * @param wrapV defines the texture wrap mode of the v coordinates
  34817. * @param wrapR defines the texture wrap mode of the r coordinates
  34818. */
  34819. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  34820. /** @hidden */
  34821. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  34822. width: number;
  34823. height: number;
  34824. layers?: number;
  34825. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  34826. /** @hidden */
  34827. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  34828. /** @hidden */
  34829. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  34830. /**
  34831. * Update a portion of an internal texture
  34832. * @param texture defines the texture to update
  34833. * @param imageData defines the data to store into the texture
  34834. * @param xOffset defines the x coordinates of the update rectangle
  34835. * @param yOffset defines the y coordinates of the update rectangle
  34836. * @param width defines the width of the update rectangle
  34837. * @param height defines the height of the update rectangle
  34838. * @param faceIndex defines the face index if texture is a cube (0 by default)
  34839. * @param lod defines the lod level to update (0 by default)
  34840. */
  34841. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  34842. /** @hidden */
  34843. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  34844. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  34845. private _prepareWebGLTexture;
  34846. /** @hidden */
  34847. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  34848. private _getDepthStencilBuffer;
  34849. /** @hidden */
  34850. _releaseFramebufferObjects(texture: InternalTexture): void;
  34851. /** @hidden */
  34852. _releaseTexture(texture: InternalTexture): void;
  34853. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  34854. protected _setProgram(program: WebGLProgram): void;
  34855. protected _boundUniforms: {
  34856. [key: number]: WebGLUniformLocation;
  34857. };
  34858. /**
  34859. * Binds an effect to the webGL context
  34860. * @param effect defines the effect to bind
  34861. */
  34862. bindSamplers(effect: Effect): void;
  34863. private _activateCurrentTexture;
  34864. /** @hidden */
  34865. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  34866. /** @hidden */
  34867. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  34868. /**
  34869. * Unbind all textures from the webGL context
  34870. */
  34871. unbindAllTextures(): void;
  34872. /**
  34873. * Sets a texture to the according uniform.
  34874. * @param channel The texture channel
  34875. * @param uniform The uniform to set
  34876. * @param texture The texture to apply
  34877. */
  34878. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  34879. private _bindSamplerUniformToChannel;
  34880. private _getTextureWrapMode;
  34881. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  34882. /**
  34883. * Sets an array of texture to the webGL context
  34884. * @param channel defines the channel where the texture array must be set
  34885. * @param uniform defines the associated uniform location
  34886. * @param textures defines the array of textures to bind
  34887. */
  34888. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  34889. /** @hidden */
  34890. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  34891. private _setTextureParameterFloat;
  34892. private _setTextureParameterInteger;
  34893. /**
  34894. * Unbind all vertex attributes from the webGL context
  34895. */
  34896. unbindAllAttributes(): void;
  34897. /**
  34898. * 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
  34899. */
  34900. releaseEffects(): void;
  34901. /**
  34902. * Dispose and release all associated resources
  34903. */
  34904. dispose(): void;
  34905. /**
  34906. * Attach a new callback raised when context lost event is fired
  34907. * @param callback defines the callback to call
  34908. */
  34909. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  34910. /**
  34911. * Attach a new callback raised when context restored event is fired
  34912. * @param callback defines the callback to call
  34913. */
  34914. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  34915. /**
  34916. * Get the current error code of the webGL context
  34917. * @returns the error code
  34918. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  34919. */
  34920. getError(): number;
  34921. private _canRenderToFloatFramebuffer;
  34922. private _canRenderToHalfFloatFramebuffer;
  34923. private _canRenderToFramebuffer;
  34924. /** @hidden */
  34925. _getWebGLTextureType(type: number): number;
  34926. /** @hidden */
  34927. _getInternalFormat(format: number): number;
  34928. /** @hidden */
  34929. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  34930. /** @hidden */
  34931. _getRGBAMultiSampleBufferFormat(type: number): number;
  34932. /** @hidden */
  34933. _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;
  34934. /**
  34935. * Loads a file from a url
  34936. * @param url url to load
  34937. * @param onSuccess callback called when the file successfully loads
  34938. * @param onProgress callback called while file is loading (if the server supports this mode)
  34939. * @param offlineProvider defines the offline provider for caching
  34940. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34941. * @param onError callback called when the file fails to load
  34942. * @returns a file request object
  34943. * @hidden
  34944. */
  34945. 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;
  34946. /**
  34947. * Reads pixels from the current frame buffer. Please note that this function can be slow
  34948. * @param x defines the x coordinate of the rectangle where pixels must be read
  34949. * @param y defines the y coordinate of the rectangle where pixels must be read
  34950. * @param width defines the width of the rectangle where pixels must be read
  34951. * @param height defines the height of the rectangle where pixels must be read
  34952. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  34953. * @returns a Uint8Array containing RGBA colors
  34954. */
  34955. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  34956. private static _isSupported;
  34957. /**
  34958. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  34959. * @returns true if the engine can be created
  34960. * @ignorenaming
  34961. */
  34962. static isSupported(): boolean;
  34963. /**
  34964. * Find the next highest power of two.
  34965. * @param x Number to start search from.
  34966. * @return Next highest power of two.
  34967. */
  34968. static CeilingPOT(x: number): number;
  34969. /**
  34970. * Find the next lowest power of two.
  34971. * @param x Number to start search from.
  34972. * @return Next lowest power of two.
  34973. */
  34974. static FloorPOT(x: number): number;
  34975. /**
  34976. * Find the nearest power of two.
  34977. * @param x Number to start search from.
  34978. * @return Next nearest power of two.
  34979. */
  34980. static NearestPOT(x: number): number;
  34981. /**
  34982. * Get the closest exponent of two
  34983. * @param value defines the value to approximate
  34984. * @param max defines the maximum value to return
  34985. * @param mode defines how to define the closest value
  34986. * @returns closest exponent of two of the given value
  34987. */
  34988. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  34989. /**
  34990. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  34991. * @param func - the function to be called
  34992. * @param requester - the object that will request the next frame. Falls back to window.
  34993. * @returns frame number
  34994. */
  34995. static QueueNewFrame(func: () => void, requester?: any): number;
  34996. /**
  34997. * Gets host document
  34998. * @returns the host document object
  34999. */
  35000. getHostDocument(): Nullable<Document>;
  35001. }
  35002. }
  35003. declare module BABYLON {
  35004. /**
  35005. * Class representing spherical harmonics coefficients to the 3rd degree
  35006. */
  35007. export class SphericalHarmonics {
  35008. /**
  35009. * Defines whether or not the harmonics have been prescaled for rendering.
  35010. */
  35011. preScaled: boolean;
  35012. /**
  35013. * The l0,0 coefficients of the spherical harmonics
  35014. */
  35015. l00: Vector3;
  35016. /**
  35017. * The l1,-1 coefficients of the spherical harmonics
  35018. */
  35019. l1_1: Vector3;
  35020. /**
  35021. * The l1,0 coefficients of the spherical harmonics
  35022. */
  35023. l10: Vector3;
  35024. /**
  35025. * The l1,1 coefficients of the spherical harmonics
  35026. */
  35027. l11: Vector3;
  35028. /**
  35029. * The l2,-2 coefficients of the spherical harmonics
  35030. */
  35031. l2_2: Vector3;
  35032. /**
  35033. * The l2,-1 coefficients of the spherical harmonics
  35034. */
  35035. l2_1: Vector3;
  35036. /**
  35037. * The l2,0 coefficients of the spherical harmonics
  35038. */
  35039. l20: Vector3;
  35040. /**
  35041. * The l2,1 coefficients of the spherical harmonics
  35042. */
  35043. l21: Vector3;
  35044. /**
  35045. * The l2,2 coefficients of the spherical harmonics
  35046. */
  35047. l22: Vector3;
  35048. /**
  35049. * Adds a light to the spherical harmonics
  35050. * @param direction the direction of the light
  35051. * @param color the color of the light
  35052. * @param deltaSolidAngle the delta solid angle of the light
  35053. */
  35054. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  35055. /**
  35056. * Scales the spherical harmonics by the given amount
  35057. * @param scale the amount to scale
  35058. */
  35059. scaleInPlace(scale: number): void;
  35060. /**
  35061. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  35062. *
  35063. * ```
  35064. * E_lm = A_l * L_lm
  35065. * ```
  35066. *
  35067. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  35068. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  35069. * the scaling factors are given in equation 9.
  35070. */
  35071. convertIncidentRadianceToIrradiance(): void;
  35072. /**
  35073. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  35074. *
  35075. * ```
  35076. * L = (1/pi) * E * rho
  35077. * ```
  35078. *
  35079. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  35080. */
  35081. convertIrradianceToLambertianRadiance(): void;
  35082. /**
  35083. * Integrates the reconstruction coefficients directly in to the SH preventing further
  35084. * required operations at run time.
  35085. *
  35086. * This is simply done by scaling back the SH with Ylm constants parameter.
  35087. * The trigonometric part being applied by the shader at run time.
  35088. */
  35089. preScaleForRendering(): void;
  35090. /**
  35091. * Constructs a spherical harmonics from an array.
  35092. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  35093. * @returns the spherical harmonics
  35094. */
  35095. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  35096. /**
  35097. * Gets the spherical harmonics from polynomial
  35098. * @param polynomial the spherical polynomial
  35099. * @returns the spherical harmonics
  35100. */
  35101. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  35102. }
  35103. /**
  35104. * Class representing spherical polynomial coefficients to the 3rd degree
  35105. */
  35106. export class SphericalPolynomial {
  35107. private _harmonics;
  35108. /**
  35109. * The spherical harmonics used to create the polynomials.
  35110. */
  35111. get preScaledHarmonics(): SphericalHarmonics;
  35112. /**
  35113. * The x coefficients of the spherical polynomial
  35114. */
  35115. x: Vector3;
  35116. /**
  35117. * The y coefficients of the spherical polynomial
  35118. */
  35119. y: Vector3;
  35120. /**
  35121. * The z coefficients of the spherical polynomial
  35122. */
  35123. z: Vector3;
  35124. /**
  35125. * The xx coefficients of the spherical polynomial
  35126. */
  35127. xx: Vector3;
  35128. /**
  35129. * The yy coefficients of the spherical polynomial
  35130. */
  35131. yy: Vector3;
  35132. /**
  35133. * The zz coefficients of the spherical polynomial
  35134. */
  35135. zz: Vector3;
  35136. /**
  35137. * The xy coefficients of the spherical polynomial
  35138. */
  35139. xy: Vector3;
  35140. /**
  35141. * The yz coefficients of the spherical polynomial
  35142. */
  35143. yz: Vector3;
  35144. /**
  35145. * The zx coefficients of the spherical polynomial
  35146. */
  35147. zx: Vector3;
  35148. /**
  35149. * Adds an ambient color to the spherical polynomial
  35150. * @param color the color to add
  35151. */
  35152. addAmbient(color: Color3): void;
  35153. /**
  35154. * Scales the spherical polynomial by the given amount
  35155. * @param scale the amount to scale
  35156. */
  35157. scaleInPlace(scale: number): void;
  35158. /**
  35159. * Gets the spherical polynomial from harmonics
  35160. * @param harmonics the spherical harmonics
  35161. * @returns the spherical polynomial
  35162. */
  35163. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  35164. /**
  35165. * Constructs a spherical polynomial from an array.
  35166. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  35167. * @returns the spherical polynomial
  35168. */
  35169. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  35170. }
  35171. }
  35172. declare module BABYLON {
  35173. /**
  35174. * Defines the source of the internal texture
  35175. */
  35176. export enum InternalTextureSource {
  35177. /**
  35178. * The source of the texture data is unknown
  35179. */
  35180. Unknown = 0,
  35181. /**
  35182. * Texture data comes from an URL
  35183. */
  35184. Url = 1,
  35185. /**
  35186. * Texture data is only used for temporary storage
  35187. */
  35188. Temp = 2,
  35189. /**
  35190. * Texture data comes from raw data (ArrayBuffer)
  35191. */
  35192. Raw = 3,
  35193. /**
  35194. * Texture content is dynamic (video or dynamic texture)
  35195. */
  35196. Dynamic = 4,
  35197. /**
  35198. * Texture content is generated by rendering to it
  35199. */
  35200. RenderTarget = 5,
  35201. /**
  35202. * Texture content is part of a multi render target process
  35203. */
  35204. MultiRenderTarget = 6,
  35205. /**
  35206. * Texture data comes from a cube data file
  35207. */
  35208. Cube = 7,
  35209. /**
  35210. * Texture data comes from a raw cube data
  35211. */
  35212. CubeRaw = 8,
  35213. /**
  35214. * Texture data come from a prefiltered cube data file
  35215. */
  35216. CubePrefiltered = 9,
  35217. /**
  35218. * Texture content is raw 3D data
  35219. */
  35220. Raw3D = 10,
  35221. /**
  35222. * Texture content is raw 2D array data
  35223. */
  35224. Raw2DArray = 11,
  35225. /**
  35226. * Texture content is a depth texture
  35227. */
  35228. Depth = 12,
  35229. /**
  35230. * Texture data comes from a raw cube data encoded with RGBD
  35231. */
  35232. CubeRawRGBD = 13
  35233. }
  35234. /**
  35235. * Class used to store data associated with WebGL texture data for the engine
  35236. * This class should not be used directly
  35237. */
  35238. export class InternalTexture {
  35239. /** @hidden */
  35240. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  35241. /**
  35242. * Defines if the texture is ready
  35243. */
  35244. isReady: boolean;
  35245. /**
  35246. * Defines if the texture is a cube texture
  35247. */
  35248. isCube: boolean;
  35249. /**
  35250. * Defines if the texture contains 3D data
  35251. */
  35252. is3D: boolean;
  35253. /**
  35254. * Defines if the texture contains 2D array data
  35255. */
  35256. is2DArray: boolean;
  35257. /**
  35258. * Defines if the texture contains multiview data
  35259. */
  35260. isMultiview: boolean;
  35261. /**
  35262. * Gets the URL used to load this texture
  35263. */
  35264. url: string;
  35265. /**
  35266. * Gets the sampling mode of the texture
  35267. */
  35268. samplingMode: number;
  35269. /**
  35270. * Gets a boolean indicating if the texture needs mipmaps generation
  35271. */
  35272. generateMipMaps: boolean;
  35273. /**
  35274. * Gets the number of samples used by the texture (WebGL2+ only)
  35275. */
  35276. samples: number;
  35277. /**
  35278. * Gets the type of the texture (int, float...)
  35279. */
  35280. type: number;
  35281. /**
  35282. * Gets the format of the texture (RGB, RGBA...)
  35283. */
  35284. format: number;
  35285. /**
  35286. * Observable called when the texture is loaded
  35287. */
  35288. onLoadedObservable: Observable<InternalTexture>;
  35289. /**
  35290. * Gets the width of the texture
  35291. */
  35292. width: number;
  35293. /**
  35294. * Gets the height of the texture
  35295. */
  35296. height: number;
  35297. /**
  35298. * Gets the depth of the texture
  35299. */
  35300. depth: number;
  35301. /**
  35302. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  35303. */
  35304. baseWidth: number;
  35305. /**
  35306. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  35307. */
  35308. baseHeight: number;
  35309. /**
  35310. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  35311. */
  35312. baseDepth: number;
  35313. /**
  35314. * Gets a boolean indicating if the texture is inverted on Y axis
  35315. */
  35316. invertY: boolean;
  35317. /** @hidden */
  35318. _invertVScale: boolean;
  35319. /** @hidden */
  35320. _associatedChannel: number;
  35321. /** @hidden */
  35322. _source: InternalTextureSource;
  35323. /** @hidden */
  35324. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  35325. /** @hidden */
  35326. _bufferView: Nullable<ArrayBufferView>;
  35327. /** @hidden */
  35328. _bufferViewArray: Nullable<ArrayBufferView[]>;
  35329. /** @hidden */
  35330. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  35331. /** @hidden */
  35332. _size: number;
  35333. /** @hidden */
  35334. _extension: string;
  35335. /** @hidden */
  35336. _files: Nullable<string[]>;
  35337. /** @hidden */
  35338. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35339. /** @hidden */
  35340. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35341. /** @hidden */
  35342. _framebuffer: Nullable<WebGLFramebuffer>;
  35343. /** @hidden */
  35344. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  35345. /** @hidden */
  35346. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  35347. /** @hidden */
  35348. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  35349. /** @hidden */
  35350. _attachments: Nullable<number[]>;
  35351. /** @hidden */
  35352. _cachedCoordinatesMode: Nullable<number>;
  35353. /** @hidden */
  35354. _cachedWrapU: Nullable<number>;
  35355. /** @hidden */
  35356. _cachedWrapV: Nullable<number>;
  35357. /** @hidden */
  35358. _cachedWrapR: Nullable<number>;
  35359. /** @hidden */
  35360. _cachedAnisotropicFilteringLevel: Nullable<number>;
  35361. /** @hidden */
  35362. _isDisabled: boolean;
  35363. /** @hidden */
  35364. _compression: Nullable<string>;
  35365. /** @hidden */
  35366. _generateStencilBuffer: boolean;
  35367. /** @hidden */
  35368. _generateDepthBuffer: boolean;
  35369. /** @hidden */
  35370. _comparisonFunction: number;
  35371. /** @hidden */
  35372. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  35373. /** @hidden */
  35374. _lodGenerationScale: number;
  35375. /** @hidden */
  35376. _lodGenerationOffset: number;
  35377. /** @hidden */
  35378. _depthStencilTexture: Nullable<InternalTexture>;
  35379. /** @hidden */
  35380. _colorTextureArray: Nullable<WebGLTexture>;
  35381. /** @hidden */
  35382. _depthStencilTextureArray: Nullable<WebGLTexture>;
  35383. /** @hidden */
  35384. _lodTextureHigh: Nullable<BaseTexture>;
  35385. /** @hidden */
  35386. _lodTextureMid: Nullable<BaseTexture>;
  35387. /** @hidden */
  35388. _lodTextureLow: Nullable<BaseTexture>;
  35389. /** @hidden */
  35390. _isRGBD: boolean;
  35391. /** @hidden */
  35392. _linearSpecularLOD: boolean;
  35393. /** @hidden */
  35394. _irradianceTexture: Nullable<BaseTexture>;
  35395. /** @hidden */
  35396. _webGLTexture: Nullable<WebGLTexture>;
  35397. /** @hidden */
  35398. _references: number;
  35399. private _engine;
  35400. /**
  35401. * Gets the Engine the texture belongs to.
  35402. * @returns The babylon engine
  35403. */
  35404. getEngine(): ThinEngine;
  35405. /**
  35406. * Gets the data source type of the texture
  35407. */
  35408. get source(): InternalTextureSource;
  35409. /**
  35410. * Creates a new InternalTexture
  35411. * @param engine defines the engine to use
  35412. * @param source defines the type of data that will be used
  35413. * @param delayAllocation if the texture allocation should be delayed (default: false)
  35414. */
  35415. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  35416. /**
  35417. * Increments the number of references (ie. the number of Texture that point to it)
  35418. */
  35419. incrementReferences(): void;
  35420. /**
  35421. * Change the size of the texture (not the size of the content)
  35422. * @param width defines the new width
  35423. * @param height defines the new height
  35424. * @param depth defines the new depth (1 by default)
  35425. */
  35426. updateSize(width: int, height: int, depth?: int): void;
  35427. /** @hidden */
  35428. _rebuild(): void;
  35429. /** @hidden */
  35430. _swapAndDie(target: InternalTexture): void;
  35431. /**
  35432. * Dispose the current allocated resources
  35433. */
  35434. dispose(): void;
  35435. }
  35436. }
  35437. declare module BABYLON {
  35438. /**
  35439. * Class used to work with sound analyzer using fast fourier transform (FFT)
  35440. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35441. */
  35442. export class Analyser {
  35443. /**
  35444. * Gets or sets the smoothing
  35445. * @ignorenaming
  35446. */
  35447. SMOOTHING: number;
  35448. /**
  35449. * Gets or sets the FFT table size
  35450. * @ignorenaming
  35451. */
  35452. FFT_SIZE: number;
  35453. /**
  35454. * Gets or sets the bar graph amplitude
  35455. * @ignorenaming
  35456. */
  35457. BARGRAPHAMPLITUDE: number;
  35458. /**
  35459. * Gets or sets the position of the debug canvas
  35460. * @ignorenaming
  35461. */
  35462. DEBUGCANVASPOS: {
  35463. x: number;
  35464. y: number;
  35465. };
  35466. /**
  35467. * Gets or sets the debug canvas size
  35468. * @ignorenaming
  35469. */
  35470. DEBUGCANVASSIZE: {
  35471. width: number;
  35472. height: number;
  35473. };
  35474. private _byteFreqs;
  35475. private _byteTime;
  35476. private _floatFreqs;
  35477. private _webAudioAnalyser;
  35478. private _debugCanvas;
  35479. private _debugCanvasContext;
  35480. private _scene;
  35481. private _registerFunc;
  35482. private _audioEngine;
  35483. /**
  35484. * Creates a new analyser
  35485. * @param scene defines hosting scene
  35486. */
  35487. constructor(scene: Scene);
  35488. /**
  35489. * Get the number of data values you will have to play with for the visualization
  35490. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  35491. * @returns a number
  35492. */
  35493. getFrequencyBinCount(): number;
  35494. /**
  35495. * Gets the current frequency data as a byte array
  35496. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35497. * @returns a Uint8Array
  35498. */
  35499. getByteFrequencyData(): Uint8Array;
  35500. /**
  35501. * Gets the current waveform as a byte array
  35502. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  35503. * @returns a Uint8Array
  35504. */
  35505. getByteTimeDomainData(): Uint8Array;
  35506. /**
  35507. * Gets the current frequency data as a float array
  35508. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35509. * @returns a Float32Array
  35510. */
  35511. getFloatFrequencyData(): Float32Array;
  35512. /**
  35513. * Renders the debug canvas
  35514. */
  35515. drawDebugCanvas(): void;
  35516. /**
  35517. * Stops rendering the debug canvas and removes it
  35518. */
  35519. stopDebugCanvas(): void;
  35520. /**
  35521. * Connects two audio nodes
  35522. * @param inputAudioNode defines first node to connect
  35523. * @param outputAudioNode defines second node to connect
  35524. */
  35525. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  35526. /**
  35527. * Releases all associated resources
  35528. */
  35529. dispose(): void;
  35530. }
  35531. }
  35532. declare module BABYLON {
  35533. /**
  35534. * This represents an audio engine and it is responsible
  35535. * to play, synchronize and analyse sounds throughout the application.
  35536. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35537. */
  35538. export interface IAudioEngine extends IDisposable {
  35539. /**
  35540. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35541. */
  35542. readonly canUseWebAudio: boolean;
  35543. /**
  35544. * Gets the current AudioContext if available.
  35545. */
  35546. readonly audioContext: Nullable<AudioContext>;
  35547. /**
  35548. * The master gain node defines the global audio volume of your audio engine.
  35549. */
  35550. readonly masterGain: GainNode;
  35551. /**
  35552. * Gets whether or not mp3 are supported by your browser.
  35553. */
  35554. readonly isMP3supported: boolean;
  35555. /**
  35556. * Gets whether or not ogg are supported by your browser.
  35557. */
  35558. readonly isOGGsupported: boolean;
  35559. /**
  35560. * Defines if Babylon should emit a warning if WebAudio is not supported.
  35561. * @ignoreNaming
  35562. */
  35563. WarnedWebAudioUnsupported: boolean;
  35564. /**
  35565. * Defines if the audio engine relies on a custom unlocked button.
  35566. * In this case, the embedded button will not be displayed.
  35567. */
  35568. useCustomUnlockedButton: boolean;
  35569. /**
  35570. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  35571. */
  35572. readonly unlocked: boolean;
  35573. /**
  35574. * Event raised when audio has been unlocked on the browser.
  35575. */
  35576. onAudioUnlockedObservable: Observable<AudioEngine>;
  35577. /**
  35578. * Event raised when audio has been locked on the browser.
  35579. */
  35580. onAudioLockedObservable: Observable<AudioEngine>;
  35581. /**
  35582. * Flags the audio engine in Locked state.
  35583. * This happens due to new browser policies preventing audio to autoplay.
  35584. */
  35585. lock(): void;
  35586. /**
  35587. * Unlocks the audio engine once a user action has been done on the dom.
  35588. * This is helpful to resume play once browser policies have been satisfied.
  35589. */
  35590. unlock(): void;
  35591. /**
  35592. * Gets the global volume sets on the master gain.
  35593. * @returns the global volume if set or -1 otherwise
  35594. */
  35595. getGlobalVolume(): number;
  35596. /**
  35597. * Sets the global volume of your experience (sets on the master gain).
  35598. * @param newVolume Defines the new global volume of the application
  35599. */
  35600. setGlobalVolume(newVolume: number): void;
  35601. /**
  35602. * Connect the audio engine to an audio analyser allowing some amazing
  35603. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35604. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35605. * @param analyser The analyser to connect to the engine
  35606. */
  35607. connectToAnalyser(analyser: Analyser): void;
  35608. }
  35609. /**
  35610. * This represents the default audio engine used in babylon.
  35611. * It is responsible to play, synchronize and analyse sounds throughout the application.
  35612. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35613. */
  35614. export class AudioEngine implements IAudioEngine {
  35615. private _audioContext;
  35616. private _audioContextInitialized;
  35617. private _muteButton;
  35618. private _hostElement;
  35619. /**
  35620. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35621. */
  35622. canUseWebAudio: boolean;
  35623. /**
  35624. * The master gain node defines the global audio volume of your audio engine.
  35625. */
  35626. masterGain: GainNode;
  35627. /**
  35628. * Defines if Babylon should emit a warning if WebAudio is not supported.
  35629. * @ignoreNaming
  35630. */
  35631. WarnedWebAudioUnsupported: boolean;
  35632. /**
  35633. * Gets whether or not mp3 are supported by your browser.
  35634. */
  35635. isMP3supported: boolean;
  35636. /**
  35637. * Gets whether or not ogg are supported by your browser.
  35638. */
  35639. isOGGsupported: boolean;
  35640. /**
  35641. * Gets whether audio has been unlocked on the device.
  35642. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  35643. * a user interaction has happened.
  35644. */
  35645. unlocked: boolean;
  35646. /**
  35647. * Defines if the audio engine relies on a custom unlocked button.
  35648. * In this case, the embedded button will not be displayed.
  35649. */
  35650. useCustomUnlockedButton: boolean;
  35651. /**
  35652. * Event raised when audio has been unlocked on the browser.
  35653. */
  35654. onAudioUnlockedObservable: Observable<AudioEngine>;
  35655. /**
  35656. * Event raised when audio has been locked on the browser.
  35657. */
  35658. onAudioLockedObservable: Observable<AudioEngine>;
  35659. /**
  35660. * Gets the current AudioContext if available.
  35661. */
  35662. get audioContext(): Nullable<AudioContext>;
  35663. private _connectedAnalyser;
  35664. /**
  35665. * Instantiates a new audio engine.
  35666. *
  35667. * There should be only one per page as some browsers restrict the number
  35668. * of audio contexts you can create.
  35669. * @param hostElement defines the host element where to display the mute icon if necessary
  35670. */
  35671. constructor(hostElement?: Nullable<HTMLElement>);
  35672. /**
  35673. * Flags the audio engine in Locked state.
  35674. * This happens due to new browser policies preventing audio to autoplay.
  35675. */
  35676. lock(): void;
  35677. /**
  35678. * Unlocks the audio engine once a user action has been done on the dom.
  35679. * This is helpful to resume play once browser policies have been satisfied.
  35680. */
  35681. unlock(): void;
  35682. private _resumeAudioContext;
  35683. private _initializeAudioContext;
  35684. private _tryToRun;
  35685. private _triggerRunningState;
  35686. private _triggerSuspendedState;
  35687. private _displayMuteButton;
  35688. private _moveButtonToTopLeft;
  35689. private _onResize;
  35690. private _hideMuteButton;
  35691. /**
  35692. * Destroy and release the resources associated with the audio ccontext.
  35693. */
  35694. dispose(): void;
  35695. /**
  35696. * Gets the global volume sets on the master gain.
  35697. * @returns the global volume if set or -1 otherwise
  35698. */
  35699. getGlobalVolume(): number;
  35700. /**
  35701. * Sets the global volume of your experience (sets on the master gain).
  35702. * @param newVolume Defines the new global volume of the application
  35703. */
  35704. setGlobalVolume(newVolume: number): void;
  35705. /**
  35706. * Connect the audio engine to an audio analyser allowing some amazing
  35707. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35708. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35709. * @param analyser The analyser to connect to the engine
  35710. */
  35711. connectToAnalyser(analyser: Analyser): void;
  35712. }
  35713. }
  35714. declare module BABYLON {
  35715. /**
  35716. * Interface used to present a loading screen while loading a scene
  35717. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35718. */
  35719. export interface ILoadingScreen {
  35720. /**
  35721. * Function called to display the loading screen
  35722. */
  35723. displayLoadingUI: () => void;
  35724. /**
  35725. * Function called to hide the loading screen
  35726. */
  35727. hideLoadingUI: () => void;
  35728. /**
  35729. * Gets or sets the color to use for the background
  35730. */
  35731. loadingUIBackgroundColor: string;
  35732. /**
  35733. * Gets or sets the text to display while loading
  35734. */
  35735. loadingUIText: string;
  35736. }
  35737. /**
  35738. * Class used for the default loading screen
  35739. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35740. */
  35741. export class DefaultLoadingScreen implements ILoadingScreen {
  35742. private _renderingCanvas;
  35743. private _loadingText;
  35744. private _loadingDivBackgroundColor;
  35745. private _loadingDiv;
  35746. private _loadingTextDiv;
  35747. /** Gets or sets the logo url to use for the default loading screen */
  35748. static DefaultLogoUrl: string;
  35749. /** Gets or sets the spinner url to use for the default loading screen */
  35750. static DefaultSpinnerUrl: string;
  35751. /**
  35752. * Creates a new default loading screen
  35753. * @param _renderingCanvas defines the canvas used to render the scene
  35754. * @param _loadingText defines the default text to display
  35755. * @param _loadingDivBackgroundColor defines the default background color
  35756. */
  35757. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  35758. /**
  35759. * Function called to display the loading screen
  35760. */
  35761. displayLoadingUI(): void;
  35762. /**
  35763. * Function called to hide the loading screen
  35764. */
  35765. hideLoadingUI(): void;
  35766. /**
  35767. * Gets or sets the text to display while loading
  35768. */
  35769. set loadingUIText(text: string);
  35770. get loadingUIText(): string;
  35771. /**
  35772. * Gets or sets the color to use for the background
  35773. */
  35774. get loadingUIBackgroundColor(): string;
  35775. set loadingUIBackgroundColor(color: string);
  35776. private _resizeLoadingUI;
  35777. }
  35778. }
  35779. declare module BABYLON {
  35780. /**
  35781. * Interface for any object that can request an animation frame
  35782. */
  35783. export interface ICustomAnimationFrameRequester {
  35784. /**
  35785. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  35786. */
  35787. renderFunction?: Function;
  35788. /**
  35789. * Called to request the next frame to render to
  35790. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  35791. */
  35792. requestAnimationFrame: Function;
  35793. /**
  35794. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  35795. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  35796. */
  35797. requestID?: number;
  35798. }
  35799. }
  35800. declare module BABYLON {
  35801. /**
  35802. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  35803. */
  35804. export class PerformanceMonitor {
  35805. private _enabled;
  35806. private _rollingFrameTime;
  35807. private _lastFrameTimeMs;
  35808. /**
  35809. * constructor
  35810. * @param frameSampleSize The number of samples required to saturate the sliding window
  35811. */
  35812. constructor(frameSampleSize?: number);
  35813. /**
  35814. * Samples current frame
  35815. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  35816. */
  35817. sampleFrame(timeMs?: number): void;
  35818. /**
  35819. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  35820. */
  35821. get averageFrameTime(): number;
  35822. /**
  35823. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  35824. */
  35825. get averageFrameTimeVariance(): number;
  35826. /**
  35827. * Returns the frame time of the most recent frame
  35828. */
  35829. get instantaneousFrameTime(): number;
  35830. /**
  35831. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  35832. */
  35833. get averageFPS(): number;
  35834. /**
  35835. * Returns the average framerate in frames per second using the most recent frame time
  35836. */
  35837. get instantaneousFPS(): number;
  35838. /**
  35839. * Returns true if enough samples have been taken to completely fill the sliding window
  35840. */
  35841. get isSaturated(): boolean;
  35842. /**
  35843. * Enables contributions to the sliding window sample set
  35844. */
  35845. enable(): void;
  35846. /**
  35847. * Disables contributions to the sliding window sample set
  35848. * Samples will not be interpolated over the disabled period
  35849. */
  35850. disable(): void;
  35851. /**
  35852. * Returns true if sampling is enabled
  35853. */
  35854. get isEnabled(): boolean;
  35855. /**
  35856. * Resets performance monitor
  35857. */
  35858. reset(): void;
  35859. }
  35860. /**
  35861. * RollingAverage
  35862. *
  35863. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  35864. */
  35865. export class RollingAverage {
  35866. /**
  35867. * Current average
  35868. */
  35869. average: number;
  35870. /**
  35871. * Current variance
  35872. */
  35873. variance: number;
  35874. protected _samples: Array<number>;
  35875. protected _sampleCount: number;
  35876. protected _pos: number;
  35877. protected _m2: number;
  35878. /**
  35879. * constructor
  35880. * @param length The number of samples required to saturate the sliding window
  35881. */
  35882. constructor(length: number);
  35883. /**
  35884. * Adds a sample to the sample set
  35885. * @param v The sample value
  35886. */
  35887. add(v: number): void;
  35888. /**
  35889. * Returns previously added values or null if outside of history or outside the sliding window domain
  35890. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  35891. * @return Value previously recorded with add() or null if outside of range
  35892. */
  35893. history(i: number): number;
  35894. /**
  35895. * Returns true if enough samples have been taken to completely fill the sliding window
  35896. * @return true if sample-set saturated
  35897. */
  35898. isSaturated(): boolean;
  35899. /**
  35900. * Resets the rolling average (equivalent to 0 samples taken so far)
  35901. */
  35902. reset(): void;
  35903. /**
  35904. * Wraps a value around the sample range boundaries
  35905. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  35906. * @return Wrapped position in sample range
  35907. */
  35908. protected _wrapPosition(i: number): number;
  35909. }
  35910. }
  35911. declare module BABYLON {
  35912. /**
  35913. * This class is used to track a performance counter which is number based.
  35914. * The user has access to many properties which give statistics of different nature.
  35915. *
  35916. * The implementer can track two kinds of Performance Counter: time and count.
  35917. * 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.
  35918. * 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.
  35919. */
  35920. export class PerfCounter {
  35921. /**
  35922. * Gets or sets a global boolean to turn on and off all the counters
  35923. */
  35924. static Enabled: boolean;
  35925. /**
  35926. * Returns the smallest value ever
  35927. */
  35928. get min(): number;
  35929. /**
  35930. * Returns the biggest value ever
  35931. */
  35932. get max(): number;
  35933. /**
  35934. * Returns the average value since the performance counter is running
  35935. */
  35936. get average(): number;
  35937. /**
  35938. * Returns the average value of the last second the counter was monitored
  35939. */
  35940. get lastSecAverage(): number;
  35941. /**
  35942. * Returns the current value
  35943. */
  35944. get current(): number;
  35945. /**
  35946. * Gets the accumulated total
  35947. */
  35948. get total(): number;
  35949. /**
  35950. * Gets the total value count
  35951. */
  35952. get count(): number;
  35953. /**
  35954. * Creates a new counter
  35955. */
  35956. constructor();
  35957. /**
  35958. * Call this method to start monitoring a new frame.
  35959. * 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.
  35960. */
  35961. fetchNewFrame(): void;
  35962. /**
  35963. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  35964. * @param newCount the count value to add to the monitored count
  35965. * @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.
  35966. */
  35967. addCount(newCount: number, fetchResult: boolean): void;
  35968. /**
  35969. * Start monitoring this performance counter
  35970. */
  35971. beginMonitoring(): void;
  35972. /**
  35973. * Compute the time lapsed since the previous beginMonitoring() call.
  35974. * @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
  35975. */
  35976. endMonitoring(newFrame?: boolean): void;
  35977. private _fetchResult;
  35978. private _startMonitoringTime;
  35979. private _min;
  35980. private _max;
  35981. private _average;
  35982. private _current;
  35983. private _totalValueCount;
  35984. private _totalAccumulated;
  35985. private _lastSecAverage;
  35986. private _lastSecAccumulated;
  35987. private _lastSecTime;
  35988. private _lastSecValueCount;
  35989. }
  35990. }
  35991. declare module BABYLON {
  35992. interface ThinEngine {
  35993. /**
  35994. * Sets alpha constants used by some alpha blending modes
  35995. * @param r defines the red component
  35996. * @param g defines the green component
  35997. * @param b defines the blue component
  35998. * @param a defines the alpha component
  35999. */
  36000. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  36001. /**
  36002. * Sets the current alpha mode
  36003. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  36004. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  36005. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36006. */
  36007. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  36008. /**
  36009. * Gets the current alpha mode
  36010. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36011. * @returns the current alpha mode
  36012. */
  36013. getAlphaMode(): number;
  36014. /**
  36015. * Sets the current alpha equation
  36016. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  36017. */
  36018. setAlphaEquation(equation: number): void;
  36019. /**
  36020. * Gets the current alpha equation.
  36021. * @returns the current alpha equation
  36022. */
  36023. getAlphaEquation(): number;
  36024. }
  36025. }
  36026. declare module BABYLON {
  36027. interface ThinEngine {
  36028. /** @hidden */
  36029. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  36030. }
  36031. }
  36032. declare module BABYLON {
  36033. /**
  36034. * Defines the interface used by display changed events
  36035. */
  36036. export interface IDisplayChangedEventArgs {
  36037. /** Gets the vrDisplay object (if any) */
  36038. vrDisplay: Nullable<any>;
  36039. /** Gets a boolean indicating if webVR is supported */
  36040. vrSupported: boolean;
  36041. }
  36042. /**
  36043. * Defines the interface used by objects containing a viewport (like a camera)
  36044. */
  36045. interface IViewportOwnerLike {
  36046. /**
  36047. * Gets or sets the viewport
  36048. */
  36049. viewport: IViewportLike;
  36050. }
  36051. /**
  36052. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  36053. */
  36054. export class Engine extends ThinEngine {
  36055. /** Defines that alpha blending is disabled */
  36056. static readonly ALPHA_DISABLE: number;
  36057. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  36058. static readonly ALPHA_ADD: number;
  36059. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  36060. static readonly ALPHA_COMBINE: number;
  36061. /** Defines that alpha blending to DEST - SRC * DEST */
  36062. static readonly ALPHA_SUBTRACT: number;
  36063. /** Defines that alpha blending to SRC * DEST */
  36064. static readonly ALPHA_MULTIPLY: number;
  36065. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  36066. static readonly ALPHA_MAXIMIZED: number;
  36067. /** Defines that alpha blending to SRC + DEST */
  36068. static readonly ALPHA_ONEONE: number;
  36069. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  36070. static readonly ALPHA_PREMULTIPLIED: number;
  36071. /**
  36072. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  36073. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  36074. */
  36075. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  36076. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  36077. static readonly ALPHA_INTERPOLATE: number;
  36078. /**
  36079. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  36080. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  36081. */
  36082. static readonly ALPHA_SCREENMODE: number;
  36083. /** Defines that the ressource is not delayed*/
  36084. static readonly DELAYLOADSTATE_NONE: number;
  36085. /** Defines that the ressource was successfully delay loaded */
  36086. static readonly DELAYLOADSTATE_LOADED: number;
  36087. /** Defines that the ressource is currently delay loading */
  36088. static readonly DELAYLOADSTATE_LOADING: number;
  36089. /** Defines that the ressource is delayed and has not started loading */
  36090. static readonly DELAYLOADSTATE_NOTLOADED: number;
  36091. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  36092. static readonly NEVER: number;
  36093. /** 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 */
  36094. static readonly ALWAYS: number;
  36095. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  36096. static readonly LESS: number;
  36097. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  36098. static readonly EQUAL: number;
  36099. /** 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 */
  36100. static readonly LEQUAL: number;
  36101. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  36102. static readonly GREATER: number;
  36103. /** 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 */
  36104. static readonly GEQUAL: number;
  36105. /** 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 */
  36106. static readonly NOTEQUAL: number;
  36107. /** Passed to stencilOperation to specify that stencil value must be kept */
  36108. static readonly KEEP: number;
  36109. /** Passed to stencilOperation to specify that stencil value must be replaced */
  36110. static readonly REPLACE: number;
  36111. /** Passed to stencilOperation to specify that stencil value must be incremented */
  36112. static readonly INCR: number;
  36113. /** Passed to stencilOperation to specify that stencil value must be decremented */
  36114. static readonly DECR: number;
  36115. /** Passed to stencilOperation to specify that stencil value must be inverted */
  36116. static readonly INVERT: number;
  36117. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  36118. static readonly INCR_WRAP: number;
  36119. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  36120. static readonly DECR_WRAP: number;
  36121. /** Texture is not repeating outside of 0..1 UVs */
  36122. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  36123. /** Texture is repeating outside of 0..1 UVs */
  36124. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  36125. /** Texture is repeating and mirrored */
  36126. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  36127. /** ALPHA */
  36128. static readonly TEXTUREFORMAT_ALPHA: number;
  36129. /** LUMINANCE */
  36130. static readonly TEXTUREFORMAT_LUMINANCE: number;
  36131. /** LUMINANCE_ALPHA */
  36132. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  36133. /** RGB */
  36134. static readonly TEXTUREFORMAT_RGB: number;
  36135. /** RGBA */
  36136. static readonly TEXTUREFORMAT_RGBA: number;
  36137. /** RED */
  36138. static readonly TEXTUREFORMAT_RED: number;
  36139. /** RED (2nd reference) */
  36140. static readonly TEXTUREFORMAT_R: number;
  36141. /** RG */
  36142. static readonly TEXTUREFORMAT_RG: number;
  36143. /** RED_INTEGER */
  36144. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  36145. /** RED_INTEGER (2nd reference) */
  36146. static readonly TEXTUREFORMAT_R_INTEGER: number;
  36147. /** RG_INTEGER */
  36148. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  36149. /** RGB_INTEGER */
  36150. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  36151. /** RGBA_INTEGER */
  36152. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  36153. /** UNSIGNED_BYTE */
  36154. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  36155. /** UNSIGNED_BYTE (2nd reference) */
  36156. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  36157. /** FLOAT */
  36158. static readonly TEXTURETYPE_FLOAT: number;
  36159. /** HALF_FLOAT */
  36160. static readonly TEXTURETYPE_HALF_FLOAT: number;
  36161. /** BYTE */
  36162. static readonly TEXTURETYPE_BYTE: number;
  36163. /** SHORT */
  36164. static readonly TEXTURETYPE_SHORT: number;
  36165. /** UNSIGNED_SHORT */
  36166. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  36167. /** INT */
  36168. static readonly TEXTURETYPE_INT: number;
  36169. /** UNSIGNED_INT */
  36170. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  36171. /** UNSIGNED_SHORT_4_4_4_4 */
  36172. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  36173. /** UNSIGNED_SHORT_5_5_5_1 */
  36174. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  36175. /** UNSIGNED_SHORT_5_6_5 */
  36176. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  36177. /** UNSIGNED_INT_2_10_10_10_REV */
  36178. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  36179. /** UNSIGNED_INT_24_8 */
  36180. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  36181. /** UNSIGNED_INT_10F_11F_11F_REV */
  36182. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  36183. /** UNSIGNED_INT_5_9_9_9_REV */
  36184. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  36185. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  36186. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  36187. /** nearest is mag = nearest and min = nearest and mip = linear */
  36188. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  36189. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36190. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  36191. /** Trilinear is mag = linear and min = linear and mip = linear */
  36192. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  36193. /** nearest is mag = nearest and min = nearest and mip = linear */
  36194. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  36195. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36196. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  36197. /** Trilinear is mag = linear and min = linear and mip = linear */
  36198. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  36199. /** mag = nearest and min = nearest and mip = nearest */
  36200. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  36201. /** mag = nearest and min = linear and mip = nearest */
  36202. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  36203. /** mag = nearest and min = linear and mip = linear */
  36204. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  36205. /** mag = nearest and min = linear and mip = none */
  36206. static readonly TEXTURE_NEAREST_LINEAR: number;
  36207. /** mag = nearest and min = nearest and mip = none */
  36208. static readonly TEXTURE_NEAREST_NEAREST: number;
  36209. /** mag = linear and min = nearest and mip = nearest */
  36210. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  36211. /** mag = linear and min = nearest and mip = linear */
  36212. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  36213. /** mag = linear and min = linear and mip = none */
  36214. static readonly TEXTURE_LINEAR_LINEAR: number;
  36215. /** mag = linear and min = nearest and mip = none */
  36216. static readonly TEXTURE_LINEAR_NEAREST: number;
  36217. /** Explicit coordinates mode */
  36218. static readonly TEXTURE_EXPLICIT_MODE: number;
  36219. /** Spherical coordinates mode */
  36220. static readonly TEXTURE_SPHERICAL_MODE: number;
  36221. /** Planar coordinates mode */
  36222. static readonly TEXTURE_PLANAR_MODE: number;
  36223. /** Cubic coordinates mode */
  36224. static readonly TEXTURE_CUBIC_MODE: number;
  36225. /** Projection coordinates mode */
  36226. static readonly TEXTURE_PROJECTION_MODE: number;
  36227. /** Skybox coordinates mode */
  36228. static readonly TEXTURE_SKYBOX_MODE: number;
  36229. /** Inverse Cubic coordinates mode */
  36230. static readonly TEXTURE_INVCUBIC_MODE: number;
  36231. /** Equirectangular coordinates mode */
  36232. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  36233. /** Equirectangular Fixed coordinates mode */
  36234. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  36235. /** Equirectangular Fixed Mirrored coordinates mode */
  36236. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  36237. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  36238. static readonly SCALEMODE_FLOOR: number;
  36239. /** Defines that texture rescaling will look for the nearest power of 2 size */
  36240. static readonly SCALEMODE_NEAREST: number;
  36241. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  36242. static readonly SCALEMODE_CEILING: number;
  36243. /**
  36244. * Returns the current npm package of the sdk
  36245. */
  36246. static get NpmPackage(): string;
  36247. /**
  36248. * Returns the current version of the framework
  36249. */
  36250. static get Version(): string;
  36251. /** Gets the list of created engines */
  36252. static get Instances(): Engine[];
  36253. /**
  36254. * Gets the latest created engine
  36255. */
  36256. static get LastCreatedEngine(): Nullable<Engine>;
  36257. /**
  36258. * Gets the latest created scene
  36259. */
  36260. static get LastCreatedScene(): Nullable<Scene>;
  36261. /**
  36262. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  36263. * @param flag defines which part of the materials must be marked as dirty
  36264. * @param predicate defines a predicate used to filter which materials should be affected
  36265. */
  36266. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36267. /**
  36268. * Method called to create the default loading screen.
  36269. * This can be overriden in your own app.
  36270. * @param canvas The rendering canvas element
  36271. * @returns The loading screen
  36272. */
  36273. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  36274. /**
  36275. * Method called to create the default rescale post process on each engine.
  36276. */
  36277. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  36278. /**
  36279. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  36280. **/
  36281. enableOfflineSupport: boolean;
  36282. /**
  36283. * 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)
  36284. **/
  36285. disableManifestCheck: boolean;
  36286. /**
  36287. * Gets the list of created scenes
  36288. */
  36289. scenes: Scene[];
  36290. /**
  36291. * Event raised when a new scene is created
  36292. */
  36293. onNewSceneAddedObservable: Observable<Scene>;
  36294. /**
  36295. * Gets the list of created postprocesses
  36296. */
  36297. postProcesses: PostProcess[];
  36298. /**
  36299. * Gets a boolean indicating if the pointer is currently locked
  36300. */
  36301. isPointerLock: boolean;
  36302. /**
  36303. * Observable event triggered each time the rendering canvas is resized
  36304. */
  36305. onResizeObservable: Observable<Engine>;
  36306. /**
  36307. * Observable event triggered each time the canvas loses focus
  36308. */
  36309. onCanvasBlurObservable: Observable<Engine>;
  36310. /**
  36311. * Observable event triggered each time the canvas gains focus
  36312. */
  36313. onCanvasFocusObservable: Observable<Engine>;
  36314. /**
  36315. * Observable event triggered each time the canvas receives pointerout event
  36316. */
  36317. onCanvasPointerOutObservable: Observable<PointerEvent>;
  36318. /**
  36319. * Observable raised when the engine begins a new frame
  36320. */
  36321. onBeginFrameObservable: Observable<Engine>;
  36322. /**
  36323. * If set, will be used to request the next animation frame for the render loop
  36324. */
  36325. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  36326. /**
  36327. * Observable raised when the engine ends the current frame
  36328. */
  36329. onEndFrameObservable: Observable<Engine>;
  36330. /**
  36331. * Observable raised when the engine is about to compile a shader
  36332. */
  36333. onBeforeShaderCompilationObservable: Observable<Engine>;
  36334. /**
  36335. * Observable raised when the engine has jsut compiled a shader
  36336. */
  36337. onAfterShaderCompilationObservable: Observable<Engine>;
  36338. /**
  36339. * Gets the audio engine
  36340. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36341. * @ignorenaming
  36342. */
  36343. static audioEngine: IAudioEngine;
  36344. /**
  36345. * Default AudioEngine factory responsible of creating the Audio Engine.
  36346. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  36347. */
  36348. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  36349. /**
  36350. * Default offline support factory responsible of creating a tool used to store data locally.
  36351. * By default, this will create a Database object if the workload has been embedded.
  36352. */
  36353. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  36354. private _loadingScreen;
  36355. private _pointerLockRequested;
  36356. private _rescalePostProcess;
  36357. private _deterministicLockstep;
  36358. private _lockstepMaxSteps;
  36359. private _timeStep;
  36360. protected get _supportsHardwareTextureRescaling(): boolean;
  36361. private _fps;
  36362. private _deltaTime;
  36363. /** @hidden */
  36364. _drawCalls: PerfCounter;
  36365. /** 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 */
  36366. canvasTabIndex: number;
  36367. /**
  36368. * Turn this value on if you want to pause FPS computation when in background
  36369. */
  36370. disablePerformanceMonitorInBackground: boolean;
  36371. private _performanceMonitor;
  36372. /**
  36373. * Gets the performance monitor attached to this engine
  36374. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  36375. */
  36376. get performanceMonitor(): PerformanceMonitor;
  36377. private _onFocus;
  36378. private _onBlur;
  36379. private _onCanvasPointerOut;
  36380. private _onCanvasBlur;
  36381. private _onCanvasFocus;
  36382. private _onFullscreenChange;
  36383. private _onPointerLockChange;
  36384. /**
  36385. * Gets the HTML element used to attach event listeners
  36386. * @returns a HTML element
  36387. */
  36388. getInputElement(): Nullable<HTMLElement>;
  36389. /**
  36390. * Creates a new engine
  36391. * @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
  36392. * @param antialias defines enable antialiasing (default: false)
  36393. * @param options defines further options to be sent to the getContext() function
  36394. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36395. */
  36396. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36397. /**
  36398. * Gets current aspect ratio
  36399. * @param viewportOwner defines the camera to use to get the aspect ratio
  36400. * @param useScreen defines if screen size must be used (or the current render target if any)
  36401. * @returns a number defining the aspect ratio
  36402. */
  36403. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  36404. /**
  36405. * Gets current screen aspect ratio
  36406. * @returns a number defining the aspect ratio
  36407. */
  36408. getScreenAspectRatio(): number;
  36409. /**
  36410. * Gets the client rect of the HTML canvas attached with the current webGL context
  36411. * @returns a client rectanglee
  36412. */
  36413. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  36414. /**
  36415. * Gets the client rect of the HTML element used for events
  36416. * @returns a client rectanglee
  36417. */
  36418. getInputElementClientRect(): Nullable<ClientRect>;
  36419. /**
  36420. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  36421. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36422. * @returns true if engine is in deterministic lock step mode
  36423. */
  36424. isDeterministicLockStep(): boolean;
  36425. /**
  36426. * Gets the max steps when engine is running in deterministic lock step
  36427. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36428. * @returns the max steps
  36429. */
  36430. getLockstepMaxSteps(): number;
  36431. /**
  36432. * Returns the time in ms between steps when using deterministic lock step.
  36433. * @returns time step in (ms)
  36434. */
  36435. getTimeStep(): number;
  36436. /**
  36437. * Force the mipmap generation for the given render target texture
  36438. * @param texture defines the render target texture to use
  36439. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  36440. */
  36441. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  36442. /** States */
  36443. /**
  36444. * Set various states to the webGL context
  36445. * @param culling defines backface culling state
  36446. * @param zOffset defines the value to apply to zOffset (0 by default)
  36447. * @param force defines if states must be applied even if cache is up to date
  36448. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  36449. */
  36450. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  36451. /**
  36452. * Set the z offset to apply to current rendering
  36453. * @param value defines the offset to apply
  36454. */
  36455. setZOffset(value: number): void;
  36456. /**
  36457. * Gets the current value of the zOffset
  36458. * @returns the current zOffset state
  36459. */
  36460. getZOffset(): number;
  36461. /**
  36462. * Enable or disable depth buffering
  36463. * @param enable defines the state to set
  36464. */
  36465. setDepthBuffer(enable: boolean): void;
  36466. /**
  36467. * Gets a boolean indicating if depth writing is enabled
  36468. * @returns the current depth writing state
  36469. */
  36470. getDepthWrite(): boolean;
  36471. /**
  36472. * Enable or disable depth writing
  36473. * @param enable defines the state to set
  36474. */
  36475. setDepthWrite(enable: boolean): void;
  36476. /**
  36477. * Gets a boolean indicating if stencil buffer is enabled
  36478. * @returns the current stencil buffer state
  36479. */
  36480. getStencilBuffer(): boolean;
  36481. /**
  36482. * Enable or disable the stencil buffer
  36483. * @param enable defines if the stencil buffer must be enabled or disabled
  36484. */
  36485. setStencilBuffer(enable: boolean): void;
  36486. /**
  36487. * Gets the current stencil mask
  36488. * @returns a number defining the new stencil mask to use
  36489. */
  36490. getStencilMask(): number;
  36491. /**
  36492. * Sets the current stencil mask
  36493. * @param mask defines the new stencil mask to use
  36494. */
  36495. setStencilMask(mask: number): void;
  36496. /**
  36497. * Gets the current stencil function
  36498. * @returns a number defining the stencil function to use
  36499. */
  36500. getStencilFunction(): number;
  36501. /**
  36502. * Gets the current stencil reference value
  36503. * @returns a number defining the stencil reference value to use
  36504. */
  36505. getStencilFunctionReference(): number;
  36506. /**
  36507. * Gets the current stencil mask
  36508. * @returns a number defining the stencil mask to use
  36509. */
  36510. getStencilFunctionMask(): number;
  36511. /**
  36512. * Sets the current stencil function
  36513. * @param stencilFunc defines the new stencil function to use
  36514. */
  36515. setStencilFunction(stencilFunc: number): void;
  36516. /**
  36517. * Sets the current stencil reference
  36518. * @param reference defines the new stencil reference to use
  36519. */
  36520. setStencilFunctionReference(reference: number): void;
  36521. /**
  36522. * Sets the current stencil mask
  36523. * @param mask defines the new stencil mask to use
  36524. */
  36525. setStencilFunctionMask(mask: number): void;
  36526. /**
  36527. * Gets the current stencil operation when stencil fails
  36528. * @returns a number defining stencil operation to use when stencil fails
  36529. */
  36530. getStencilOperationFail(): number;
  36531. /**
  36532. * Gets the current stencil operation when depth fails
  36533. * @returns a number defining stencil operation to use when depth fails
  36534. */
  36535. getStencilOperationDepthFail(): number;
  36536. /**
  36537. * Gets the current stencil operation when stencil passes
  36538. * @returns a number defining stencil operation to use when stencil passes
  36539. */
  36540. getStencilOperationPass(): number;
  36541. /**
  36542. * Sets the stencil operation to use when stencil fails
  36543. * @param operation defines the stencil operation to use when stencil fails
  36544. */
  36545. setStencilOperationFail(operation: number): void;
  36546. /**
  36547. * Sets the stencil operation to use when depth fails
  36548. * @param operation defines the stencil operation to use when depth fails
  36549. */
  36550. setStencilOperationDepthFail(operation: number): void;
  36551. /**
  36552. * Sets the stencil operation to use when stencil passes
  36553. * @param operation defines the stencil operation to use when stencil passes
  36554. */
  36555. setStencilOperationPass(operation: number): void;
  36556. /**
  36557. * Sets a boolean indicating if the dithering state is enabled or disabled
  36558. * @param value defines the dithering state
  36559. */
  36560. setDitheringState(value: boolean): void;
  36561. /**
  36562. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  36563. * @param value defines the rasterizer state
  36564. */
  36565. setRasterizerState(value: boolean): void;
  36566. /**
  36567. * Gets the current depth function
  36568. * @returns a number defining the depth function
  36569. */
  36570. getDepthFunction(): Nullable<number>;
  36571. /**
  36572. * Sets the current depth function
  36573. * @param depthFunc defines the function to use
  36574. */
  36575. setDepthFunction(depthFunc: number): void;
  36576. /**
  36577. * Sets the current depth function to GREATER
  36578. */
  36579. setDepthFunctionToGreater(): void;
  36580. /**
  36581. * Sets the current depth function to GEQUAL
  36582. */
  36583. setDepthFunctionToGreaterOrEqual(): void;
  36584. /**
  36585. * Sets the current depth function to LESS
  36586. */
  36587. setDepthFunctionToLess(): void;
  36588. /**
  36589. * Sets the current depth function to LEQUAL
  36590. */
  36591. setDepthFunctionToLessOrEqual(): void;
  36592. private _cachedStencilBuffer;
  36593. private _cachedStencilFunction;
  36594. private _cachedStencilMask;
  36595. private _cachedStencilOperationPass;
  36596. private _cachedStencilOperationFail;
  36597. private _cachedStencilOperationDepthFail;
  36598. private _cachedStencilReference;
  36599. /**
  36600. * Caches the the state of the stencil buffer
  36601. */
  36602. cacheStencilState(): void;
  36603. /**
  36604. * Restores the state of the stencil buffer
  36605. */
  36606. restoreStencilState(): void;
  36607. /**
  36608. * Directly set the WebGL Viewport
  36609. * @param x defines the x coordinate of the viewport (in screen space)
  36610. * @param y defines the y coordinate of the viewport (in screen space)
  36611. * @param width defines the width of the viewport (in screen space)
  36612. * @param height defines the height of the viewport (in screen space)
  36613. * @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
  36614. */
  36615. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  36616. /**
  36617. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  36618. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  36619. * @param y defines the y-coordinate of the corner of the clear rectangle
  36620. * @param width defines the width of the clear rectangle
  36621. * @param height defines the height of the clear rectangle
  36622. * @param clearColor defines the clear color
  36623. */
  36624. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  36625. /**
  36626. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  36627. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  36628. * @param y defines the y-coordinate of the corner of the clear rectangle
  36629. * @param width defines the width of the clear rectangle
  36630. * @param height defines the height of the clear rectangle
  36631. */
  36632. enableScissor(x: number, y: number, width: number, height: number): void;
  36633. /**
  36634. * Disable previously set scissor test rectangle
  36635. */
  36636. disableScissor(): void;
  36637. protected _reportDrawCall(): void;
  36638. /**
  36639. * Initializes a webVR display and starts listening to display change events
  36640. * The onVRDisplayChangedObservable will be notified upon these changes
  36641. * @returns The onVRDisplayChangedObservable
  36642. */
  36643. initWebVR(): Observable<IDisplayChangedEventArgs>;
  36644. /** @hidden */
  36645. _prepareVRComponent(): void;
  36646. /** @hidden */
  36647. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  36648. /** @hidden */
  36649. _submitVRFrame(): void;
  36650. /**
  36651. * Call this function to leave webVR mode
  36652. * Will do nothing if webVR is not supported or if there is no webVR device
  36653. * @see http://doc.babylonjs.com/how_to/webvr_camera
  36654. */
  36655. disableVR(): void;
  36656. /**
  36657. * Gets a boolean indicating that the system is in VR mode and is presenting
  36658. * @returns true if VR mode is engaged
  36659. */
  36660. isVRPresenting(): boolean;
  36661. /** @hidden */
  36662. _requestVRFrame(): void;
  36663. /** @hidden */
  36664. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36665. /**
  36666. * Gets the source code of the vertex shader associated with a specific webGL program
  36667. * @param program defines the program to use
  36668. * @returns a string containing the source code of the vertex shader associated with the program
  36669. */
  36670. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  36671. /**
  36672. * Gets the source code of the fragment shader associated with a specific webGL program
  36673. * @param program defines the program to use
  36674. * @returns a string containing the source code of the fragment shader associated with the program
  36675. */
  36676. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  36677. /**
  36678. * Sets a depth stencil texture from a render target to the according uniform.
  36679. * @param channel The texture channel
  36680. * @param uniform The uniform to set
  36681. * @param texture The render target texture containing the depth stencil texture to apply
  36682. */
  36683. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  36684. /**
  36685. * Sets a texture to the webGL context from a postprocess
  36686. * @param channel defines the channel to use
  36687. * @param postProcess defines the source postprocess
  36688. */
  36689. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  36690. /**
  36691. * Binds the output of the passed in post process to the texture channel specified
  36692. * @param channel The channel the texture should be bound to
  36693. * @param postProcess The post process which's output should be bound
  36694. */
  36695. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  36696. protected _rebuildBuffers(): void;
  36697. /** @hidden */
  36698. _renderFrame(): void;
  36699. _renderLoop(): void;
  36700. /** @hidden */
  36701. _renderViews(): boolean;
  36702. /**
  36703. * Toggle full screen mode
  36704. * @param requestPointerLock defines if a pointer lock should be requested from the user
  36705. */
  36706. switchFullscreen(requestPointerLock: boolean): void;
  36707. /**
  36708. * Enters full screen mode
  36709. * @param requestPointerLock defines if a pointer lock should be requested from the user
  36710. */
  36711. enterFullscreen(requestPointerLock: boolean): void;
  36712. /**
  36713. * Exits full screen mode
  36714. */
  36715. exitFullscreen(): void;
  36716. /**
  36717. * Enters Pointerlock mode
  36718. */
  36719. enterPointerlock(): void;
  36720. /**
  36721. * Exits Pointerlock mode
  36722. */
  36723. exitPointerlock(): void;
  36724. /**
  36725. * Begin a new frame
  36726. */
  36727. beginFrame(): void;
  36728. /**
  36729. * Enf the current frame
  36730. */
  36731. endFrame(): void;
  36732. resize(): void;
  36733. /**
  36734. * Force a specific size of the canvas
  36735. * @param width defines the new canvas' width
  36736. * @param height defines the new canvas' height
  36737. */
  36738. setSize(width: number, height: number): void;
  36739. /**
  36740. * Updates a dynamic vertex buffer.
  36741. * @param vertexBuffer the vertex buffer to update
  36742. * @param data the data used to update the vertex buffer
  36743. * @param byteOffset the byte offset of the data
  36744. * @param byteLength the byte length of the data
  36745. */
  36746. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  36747. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  36748. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36749. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36750. _releaseTexture(texture: InternalTexture): void;
  36751. /**
  36752. * @hidden
  36753. * Rescales a texture
  36754. * @param source input texutre
  36755. * @param destination destination texture
  36756. * @param scene scene to use to render the resize
  36757. * @param internalFormat format to use when resizing
  36758. * @param onComplete callback to be called when resize has completed
  36759. */
  36760. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  36761. /**
  36762. * Gets the current framerate
  36763. * @returns a number representing the framerate
  36764. */
  36765. getFps(): number;
  36766. /**
  36767. * Gets the time spent between current and previous frame
  36768. * @returns a number representing the delta time in ms
  36769. */
  36770. getDeltaTime(): number;
  36771. private _measureFps;
  36772. /** @hidden */
  36773. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  36774. /**
  36775. * Update a dynamic index buffer
  36776. * @param indexBuffer defines the target index buffer
  36777. * @param indices defines the data to update
  36778. * @param offset defines the offset in the target index buffer where update should start
  36779. */
  36780. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  36781. /**
  36782. * Updates the sample count of a render target texture
  36783. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  36784. * @param texture defines the texture to update
  36785. * @param samples defines the sample count to set
  36786. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  36787. */
  36788. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  36789. /**
  36790. * Updates a depth texture Comparison Mode and Function.
  36791. * If the comparison Function is equal to 0, the mode will be set to none.
  36792. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  36793. * @param texture The texture to set the comparison function for
  36794. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  36795. */
  36796. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  36797. /**
  36798. * Creates a webGL buffer to use with instanciation
  36799. * @param capacity defines the size of the buffer
  36800. * @returns the webGL buffer
  36801. */
  36802. createInstancesBuffer(capacity: number): DataBuffer;
  36803. /**
  36804. * Delete a webGL buffer used with instanciation
  36805. * @param buffer defines the webGL buffer to delete
  36806. */
  36807. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  36808. private _clientWaitAsync;
  36809. /** @hidden */
  36810. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  36811. dispose(): void;
  36812. private _disableTouchAction;
  36813. /**
  36814. * Display the loading screen
  36815. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36816. */
  36817. displayLoadingUI(): void;
  36818. /**
  36819. * Hide the loading screen
  36820. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36821. */
  36822. hideLoadingUI(): void;
  36823. /**
  36824. * Gets the current loading screen object
  36825. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36826. */
  36827. get loadingScreen(): ILoadingScreen;
  36828. /**
  36829. * Sets the current loading screen object
  36830. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36831. */
  36832. set loadingScreen(loadingScreen: ILoadingScreen);
  36833. /**
  36834. * Sets the current loading screen text
  36835. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36836. */
  36837. set loadingUIText(text: string);
  36838. /**
  36839. * Sets the current loading screen background color
  36840. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36841. */
  36842. set loadingUIBackgroundColor(color: string);
  36843. /** Pointerlock and fullscreen */
  36844. /**
  36845. * Ask the browser to promote the current element to pointerlock mode
  36846. * @param element defines the DOM element to promote
  36847. */
  36848. static _RequestPointerlock(element: HTMLElement): void;
  36849. /**
  36850. * Asks the browser to exit pointerlock mode
  36851. */
  36852. static _ExitPointerlock(): void;
  36853. /**
  36854. * Ask the browser to promote the current element to fullscreen rendering mode
  36855. * @param element defines the DOM element to promote
  36856. */
  36857. static _RequestFullscreen(element: HTMLElement): void;
  36858. /**
  36859. * Asks the browser to exit fullscreen mode
  36860. */
  36861. static _ExitFullscreen(): void;
  36862. }
  36863. }
  36864. declare module BABYLON {
  36865. /**
  36866. * The engine store class is responsible to hold all the instances of Engine and Scene created
  36867. * during the life time of the application.
  36868. */
  36869. export class EngineStore {
  36870. /** Gets the list of created engines */
  36871. static Instances: Engine[];
  36872. /** @hidden */
  36873. static _LastCreatedScene: Nullable<Scene>;
  36874. /**
  36875. * Gets the latest created engine
  36876. */
  36877. static get LastCreatedEngine(): Nullable<Engine>;
  36878. /**
  36879. * Gets the latest created scene
  36880. */
  36881. static get LastCreatedScene(): Nullable<Scene>;
  36882. /**
  36883. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  36884. * @ignorenaming
  36885. */
  36886. static UseFallbackTexture: boolean;
  36887. /**
  36888. * Texture content used if a texture cannot loaded
  36889. * @ignorenaming
  36890. */
  36891. static FallbackTexture: string;
  36892. }
  36893. }
  36894. declare module BABYLON {
  36895. /**
  36896. * Helper class that provides a small promise polyfill
  36897. */
  36898. export class PromisePolyfill {
  36899. /**
  36900. * Static function used to check if the polyfill is required
  36901. * If this is the case then the function will inject the polyfill to window.Promise
  36902. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  36903. */
  36904. static Apply(force?: boolean): void;
  36905. }
  36906. }
  36907. declare module BABYLON {
  36908. /**
  36909. * Interface for screenshot methods with describe argument called `size` as object with options
  36910. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  36911. */
  36912. export interface IScreenshotSize {
  36913. /**
  36914. * number in pixels for canvas height
  36915. */
  36916. height?: number;
  36917. /**
  36918. * multiplier allowing render at a higher or lower resolution
  36919. * If value is defined then height and width will be ignored and taken from camera
  36920. */
  36921. precision?: number;
  36922. /**
  36923. * number in pixels for canvas width
  36924. */
  36925. width?: number;
  36926. }
  36927. }
  36928. declare module BABYLON {
  36929. interface IColor4Like {
  36930. r: float;
  36931. g: float;
  36932. b: float;
  36933. a: float;
  36934. }
  36935. /**
  36936. * Class containing a set of static utilities functions
  36937. */
  36938. export class Tools {
  36939. /**
  36940. * Gets or sets the base URL to use to load assets
  36941. */
  36942. static get BaseUrl(): string;
  36943. static set BaseUrl(value: string);
  36944. /**
  36945. * Enable/Disable Custom HTTP Request Headers globally.
  36946. * default = false
  36947. * @see CustomRequestHeaders
  36948. */
  36949. static UseCustomRequestHeaders: boolean;
  36950. /**
  36951. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  36952. * i.e. when loading files, where the server/service expects an Authorization header
  36953. */
  36954. static CustomRequestHeaders: {
  36955. [key: string]: string;
  36956. };
  36957. /**
  36958. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  36959. */
  36960. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  36961. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  36962. /**
  36963. * Default behaviour for cors in the application.
  36964. * It can be a string if the expected behavior is identical in the entire app.
  36965. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  36966. */
  36967. static get CorsBehavior(): string | ((url: string | string[]) => string);
  36968. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  36969. /**
  36970. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  36971. * @ignorenaming
  36972. */
  36973. static get UseFallbackTexture(): boolean;
  36974. static set UseFallbackTexture(value: boolean);
  36975. /**
  36976. * Use this object to register external classes like custom textures or material
  36977. * to allow the laoders to instantiate them
  36978. */
  36979. static get RegisteredExternalClasses(): {
  36980. [key: string]: Object;
  36981. };
  36982. static set RegisteredExternalClasses(classes: {
  36983. [key: string]: Object;
  36984. });
  36985. /**
  36986. * Texture content used if a texture cannot loaded
  36987. * @ignorenaming
  36988. */
  36989. static get fallbackTexture(): string;
  36990. static set fallbackTexture(value: string);
  36991. /**
  36992. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  36993. * @param u defines the coordinate on X axis
  36994. * @param v defines the coordinate on Y axis
  36995. * @param width defines the width of the source data
  36996. * @param height defines the height of the source data
  36997. * @param pixels defines the source byte array
  36998. * @param color defines the output color
  36999. */
  37000. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  37001. /**
  37002. * Interpolates between a and b via alpha
  37003. * @param a The lower value (returned when alpha = 0)
  37004. * @param b The upper value (returned when alpha = 1)
  37005. * @param alpha The interpolation-factor
  37006. * @return The mixed value
  37007. */
  37008. static Mix(a: number, b: number, alpha: number): number;
  37009. /**
  37010. * Tries to instantiate a new object from a given class name
  37011. * @param className defines the class name to instantiate
  37012. * @returns the new object or null if the system was not able to do the instantiation
  37013. */
  37014. static Instantiate(className: string): any;
  37015. /**
  37016. * Provides a slice function that will work even on IE
  37017. * @param data defines the array to slice
  37018. * @param start defines the start of the data (optional)
  37019. * @param end defines the end of the data (optional)
  37020. * @returns the new sliced array
  37021. */
  37022. static Slice<T>(data: T, start?: number, end?: number): T;
  37023. /**
  37024. * Polyfill for setImmediate
  37025. * @param action defines the action to execute after the current execution block
  37026. */
  37027. static SetImmediate(action: () => void): void;
  37028. /**
  37029. * Function indicating if a number is an exponent of 2
  37030. * @param value defines the value to test
  37031. * @returns true if the value is an exponent of 2
  37032. */
  37033. static IsExponentOfTwo(value: number): boolean;
  37034. private static _tmpFloatArray;
  37035. /**
  37036. * Returns the nearest 32-bit single precision float representation of a Number
  37037. * @param value A Number. If the parameter is of a different type, it will get converted
  37038. * to a number or to NaN if it cannot be converted
  37039. * @returns number
  37040. */
  37041. static FloatRound(value: number): number;
  37042. /**
  37043. * Extracts the filename from a path
  37044. * @param path defines the path to use
  37045. * @returns the filename
  37046. */
  37047. static GetFilename(path: string): string;
  37048. /**
  37049. * Extracts the "folder" part of a path (everything before the filename).
  37050. * @param uri The URI to extract the info from
  37051. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  37052. * @returns The "folder" part of the path
  37053. */
  37054. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  37055. /**
  37056. * Extracts text content from a DOM element hierarchy
  37057. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  37058. */
  37059. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  37060. /**
  37061. * Convert an angle in radians to degrees
  37062. * @param angle defines the angle to convert
  37063. * @returns the angle in degrees
  37064. */
  37065. static ToDegrees(angle: number): number;
  37066. /**
  37067. * Convert an angle in degrees to radians
  37068. * @param angle defines the angle to convert
  37069. * @returns the angle in radians
  37070. */
  37071. static ToRadians(angle: number): number;
  37072. /**
  37073. * Returns an array if obj is not an array
  37074. * @param obj defines the object to evaluate as an array
  37075. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  37076. * @returns either obj directly if obj is an array or a new array containing obj
  37077. */
  37078. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  37079. /**
  37080. * Gets the pointer prefix to use
  37081. * @returns "pointer" if touch is enabled. Else returns "mouse"
  37082. */
  37083. static GetPointerPrefix(): string;
  37084. /**
  37085. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  37086. * @param url define the url we are trying
  37087. * @param element define the dom element where to configure the cors policy
  37088. */
  37089. static SetCorsBehavior(url: string | string[], element: {
  37090. crossOrigin: string | null;
  37091. }): void;
  37092. /**
  37093. * Removes unwanted characters from an url
  37094. * @param url defines the url to clean
  37095. * @returns the cleaned url
  37096. */
  37097. static CleanUrl(url: string): string;
  37098. /**
  37099. * Gets or sets a function used to pre-process url before using them to load assets
  37100. */
  37101. static get PreprocessUrl(): (url: string) => string;
  37102. static set PreprocessUrl(processor: (url: string) => string);
  37103. /**
  37104. * Loads an image as an HTMLImageElement.
  37105. * @param input url string, ArrayBuffer, or Blob to load
  37106. * @param onLoad callback called when the image successfully loads
  37107. * @param onError callback called when the image fails to load
  37108. * @param offlineProvider offline provider for caching
  37109. * @param mimeType optional mime type
  37110. * @returns the HTMLImageElement of the loaded image
  37111. */
  37112. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  37113. /**
  37114. * Loads a file from a url
  37115. * @param url url string, ArrayBuffer, or Blob to load
  37116. * @param onSuccess callback called when the file successfully loads
  37117. * @param onProgress callback called while file is loading (if the server supports this mode)
  37118. * @param offlineProvider defines the offline provider for caching
  37119. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37120. * @param onError callback called when the file fails to load
  37121. * @returns a file request object
  37122. */
  37123. 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;
  37124. /**
  37125. * Loads a file from a url
  37126. * @param url the file url to load
  37127. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37128. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  37129. */
  37130. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  37131. /**
  37132. * Load a script (identified by an url). When the url returns, the
  37133. * content of this file is added into a new script element, attached to the DOM (body element)
  37134. * @param scriptUrl defines the url of the script to laod
  37135. * @param onSuccess defines the callback called when the script is loaded
  37136. * @param onError defines the callback to call if an error occurs
  37137. * @param scriptId defines the id of the script element
  37138. */
  37139. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  37140. /**
  37141. * Load an asynchronous script (identified by an url). When the url returns, the
  37142. * content of this file is added into a new script element, attached to the DOM (body element)
  37143. * @param scriptUrl defines the url of the script to laod
  37144. * @param scriptId defines the id of the script element
  37145. * @returns a promise request object
  37146. */
  37147. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  37148. /**
  37149. * Loads a file from a blob
  37150. * @param fileToLoad defines the blob to use
  37151. * @param callback defines the callback to call when data is loaded
  37152. * @param progressCallback defines the callback to call during loading process
  37153. * @returns a file request object
  37154. */
  37155. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  37156. /**
  37157. * Reads a file from a File object
  37158. * @param file defines the file to load
  37159. * @param onSuccess defines the callback to call when data is loaded
  37160. * @param onProgress defines the callback to call during loading process
  37161. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  37162. * @param onError defines the callback to call when an error occurs
  37163. * @returns a file request object
  37164. */
  37165. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37166. /**
  37167. * Creates a data url from a given string content
  37168. * @param content defines the content to convert
  37169. * @returns the new data url link
  37170. */
  37171. static FileAsURL(content: string): string;
  37172. /**
  37173. * Format the given number to a specific decimal format
  37174. * @param value defines the number to format
  37175. * @param decimals defines the number of decimals to use
  37176. * @returns the formatted string
  37177. */
  37178. static Format(value: number, decimals?: number): string;
  37179. /**
  37180. * Tries to copy an object by duplicating every property
  37181. * @param source defines the source object
  37182. * @param destination defines the target object
  37183. * @param doNotCopyList defines a list of properties to avoid
  37184. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  37185. */
  37186. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  37187. /**
  37188. * Gets a boolean indicating if the given object has no own property
  37189. * @param obj defines the object to test
  37190. * @returns true if object has no own property
  37191. */
  37192. static IsEmpty(obj: any): boolean;
  37193. /**
  37194. * Function used to register events at window level
  37195. * @param windowElement defines the Window object to use
  37196. * @param events defines the events to register
  37197. */
  37198. static RegisterTopRootEvents(windowElement: Window, events: {
  37199. name: string;
  37200. handler: Nullable<(e: FocusEvent) => any>;
  37201. }[]): void;
  37202. /**
  37203. * Function used to unregister events from window level
  37204. * @param windowElement defines the Window object to use
  37205. * @param events defines the events to unregister
  37206. */
  37207. static UnregisterTopRootEvents(windowElement: Window, events: {
  37208. name: string;
  37209. handler: Nullable<(e: FocusEvent) => any>;
  37210. }[]): void;
  37211. /**
  37212. * @ignore
  37213. */
  37214. static _ScreenshotCanvas: HTMLCanvasElement;
  37215. /**
  37216. * Dumps the current bound framebuffer
  37217. * @param width defines the rendering width
  37218. * @param height defines the rendering height
  37219. * @param engine defines the hosting engine
  37220. * @param successCallback defines the callback triggered once the data are available
  37221. * @param mimeType defines the mime type of the result
  37222. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  37223. */
  37224. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37225. /**
  37226. * Converts the canvas data to blob.
  37227. * This acts as a polyfill for browsers not supporting the to blob function.
  37228. * @param canvas Defines the canvas to extract the data from
  37229. * @param successCallback Defines the callback triggered once the data are available
  37230. * @param mimeType Defines the mime type of the result
  37231. */
  37232. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  37233. /**
  37234. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  37235. * @param successCallback defines the callback triggered once the data are available
  37236. * @param mimeType defines the mime type of the result
  37237. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  37238. */
  37239. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37240. /**
  37241. * Downloads a blob in the browser
  37242. * @param blob defines the blob to download
  37243. * @param fileName defines the name of the downloaded file
  37244. */
  37245. static Download(blob: Blob, fileName: string): void;
  37246. /**
  37247. * Captures a screenshot of the current rendering
  37248. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37249. * @param engine defines the rendering engine
  37250. * @param camera defines the source camera
  37251. * @param size This parameter can be set to a single number or to an object with the
  37252. * following (optional) properties: precision, width, height. If a single number is passed,
  37253. * it will be used for both width and height. If an object is passed, the screenshot size
  37254. * will be derived from the parameters. The precision property is a multiplier allowing
  37255. * rendering at a higher or lower resolution
  37256. * @param successCallback defines the callback receives a single parameter which contains the
  37257. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37258. * src parameter of an <img> to display it
  37259. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  37260. * Check your browser for supported MIME types
  37261. */
  37262. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  37263. /**
  37264. * Captures a screenshot of the current rendering
  37265. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37266. * @param engine defines the rendering engine
  37267. * @param camera defines the source camera
  37268. * @param size This parameter can be set to a single number or to an object with the
  37269. * following (optional) properties: precision, width, height. If a single number is passed,
  37270. * it will be used for both width and height. If an object is passed, the screenshot size
  37271. * will be derived from the parameters. The precision property is a multiplier allowing
  37272. * rendering at a higher or lower resolution
  37273. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  37274. * Check your browser for supported MIME types
  37275. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37276. * to the src parameter of an <img> to display it
  37277. */
  37278. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  37279. /**
  37280. * Generates an image screenshot from the specified camera.
  37281. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37282. * @param engine The engine to use for rendering
  37283. * @param camera The camera to use for rendering
  37284. * @param size This parameter can be set to a single number or to an object with the
  37285. * following (optional) properties: precision, width, height. If a single number is passed,
  37286. * it will be used for both width and height. If an object is passed, the screenshot size
  37287. * will be derived from the parameters. The precision property is a multiplier allowing
  37288. * rendering at a higher or lower resolution
  37289. * @param successCallback The callback receives a single parameter which contains the
  37290. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37291. * src parameter of an <img> to display it
  37292. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37293. * Check your browser for supported MIME types
  37294. * @param samples Texture samples (default: 1)
  37295. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37296. * @param fileName A name for for the downloaded file.
  37297. */
  37298. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  37299. /**
  37300. * Generates an image screenshot from the specified camera.
  37301. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37302. * @param engine The engine to use for rendering
  37303. * @param camera The camera to use for rendering
  37304. * @param size This parameter can be set to a single number or to an object with the
  37305. * following (optional) properties: precision, width, height. If a single number is passed,
  37306. * it will be used for both width and height. If an object is passed, the screenshot size
  37307. * will be derived from the parameters. The precision property is a multiplier allowing
  37308. * rendering at a higher or lower resolution
  37309. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37310. * Check your browser for supported MIME types
  37311. * @param samples Texture samples (default: 1)
  37312. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37313. * @param fileName A name for for the downloaded file.
  37314. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37315. * to the src parameter of an <img> to display it
  37316. */
  37317. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  37318. /**
  37319. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  37320. * Be aware Math.random() could cause collisions, but:
  37321. * "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"
  37322. * @returns a pseudo random id
  37323. */
  37324. static RandomId(): string;
  37325. /**
  37326. * Test if the given uri is a base64 string
  37327. * @param uri The uri to test
  37328. * @return True if the uri is a base64 string or false otherwise
  37329. */
  37330. static IsBase64(uri: string): boolean;
  37331. /**
  37332. * Decode the given base64 uri.
  37333. * @param uri The uri to decode
  37334. * @return The decoded base64 data.
  37335. */
  37336. static DecodeBase64(uri: string): ArrayBuffer;
  37337. /**
  37338. * Gets the absolute url.
  37339. * @param url the input url
  37340. * @return the absolute url
  37341. */
  37342. static GetAbsoluteUrl(url: string): string;
  37343. /**
  37344. * No log
  37345. */
  37346. static readonly NoneLogLevel: number;
  37347. /**
  37348. * Only message logs
  37349. */
  37350. static readonly MessageLogLevel: number;
  37351. /**
  37352. * Only warning logs
  37353. */
  37354. static readonly WarningLogLevel: number;
  37355. /**
  37356. * Only error logs
  37357. */
  37358. static readonly ErrorLogLevel: number;
  37359. /**
  37360. * All logs
  37361. */
  37362. static readonly AllLogLevel: number;
  37363. /**
  37364. * Gets a value indicating the number of loading errors
  37365. * @ignorenaming
  37366. */
  37367. static get errorsCount(): number;
  37368. /**
  37369. * Callback called when a new log is added
  37370. */
  37371. static OnNewCacheEntry: (entry: string) => void;
  37372. /**
  37373. * Log a message to the console
  37374. * @param message defines the message to log
  37375. */
  37376. static Log(message: string): void;
  37377. /**
  37378. * Write a warning message to the console
  37379. * @param message defines the message to log
  37380. */
  37381. static Warn(message: string): void;
  37382. /**
  37383. * Write an error message to the console
  37384. * @param message defines the message to log
  37385. */
  37386. static Error(message: string): void;
  37387. /**
  37388. * Gets current log cache (list of logs)
  37389. */
  37390. static get LogCache(): string;
  37391. /**
  37392. * Clears the log cache
  37393. */
  37394. static ClearLogCache(): void;
  37395. /**
  37396. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  37397. */
  37398. static set LogLevels(level: number);
  37399. /**
  37400. * Checks if the window object exists
  37401. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  37402. */
  37403. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  37404. /**
  37405. * No performance log
  37406. */
  37407. static readonly PerformanceNoneLogLevel: number;
  37408. /**
  37409. * Use user marks to log performance
  37410. */
  37411. static readonly PerformanceUserMarkLogLevel: number;
  37412. /**
  37413. * Log performance to the console
  37414. */
  37415. static readonly PerformanceConsoleLogLevel: number;
  37416. private static _performance;
  37417. /**
  37418. * Sets the current performance log level
  37419. */
  37420. static set PerformanceLogLevel(level: number);
  37421. private static _StartPerformanceCounterDisabled;
  37422. private static _EndPerformanceCounterDisabled;
  37423. private static _StartUserMark;
  37424. private static _EndUserMark;
  37425. private static _StartPerformanceConsole;
  37426. private static _EndPerformanceConsole;
  37427. /**
  37428. * Starts a performance counter
  37429. */
  37430. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37431. /**
  37432. * Ends a specific performance coutner
  37433. */
  37434. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37435. /**
  37436. * Gets either window.performance.now() if supported or Date.now() else
  37437. */
  37438. static get Now(): number;
  37439. /**
  37440. * This method will return the name of the class used to create the instance of the given object.
  37441. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  37442. * @param object the object to get the class name from
  37443. * @param isType defines if the object is actually a type
  37444. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  37445. */
  37446. static GetClassName(object: any, isType?: boolean): string;
  37447. /**
  37448. * Gets the first element of an array satisfying a given predicate
  37449. * @param array defines the array to browse
  37450. * @param predicate defines the predicate to use
  37451. * @returns null if not found or the element
  37452. */
  37453. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  37454. /**
  37455. * This method will return the name of the full name of the class, including its owning module (if any).
  37456. * 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).
  37457. * @param object the object to get the class name from
  37458. * @param isType defines if the object is actually a type
  37459. * @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.
  37460. * @ignorenaming
  37461. */
  37462. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  37463. /**
  37464. * Returns a promise that resolves after the given amount of time.
  37465. * @param delay Number of milliseconds to delay
  37466. * @returns Promise that resolves after the given amount of time
  37467. */
  37468. static DelayAsync(delay: number): Promise<void>;
  37469. /**
  37470. * Utility function to detect if the current user agent is Safari
  37471. * @returns whether or not the current user agent is safari
  37472. */
  37473. static IsSafari(): boolean;
  37474. }
  37475. /**
  37476. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  37477. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  37478. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  37479. * @param name The name of the class, case should be preserved
  37480. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  37481. */
  37482. export function className(name: string, module?: string): (target: Object) => void;
  37483. /**
  37484. * An implementation of a loop for asynchronous functions.
  37485. */
  37486. export class AsyncLoop {
  37487. /**
  37488. * Defines the number of iterations for the loop
  37489. */
  37490. iterations: number;
  37491. /**
  37492. * Defines the current index of the loop.
  37493. */
  37494. index: number;
  37495. private _done;
  37496. private _fn;
  37497. private _successCallback;
  37498. /**
  37499. * Constructor.
  37500. * @param iterations the number of iterations.
  37501. * @param func the function to run each iteration
  37502. * @param successCallback the callback that will be called upon succesful execution
  37503. * @param offset starting offset.
  37504. */
  37505. constructor(
  37506. /**
  37507. * Defines the number of iterations for the loop
  37508. */
  37509. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  37510. /**
  37511. * Execute the next iteration. Must be called after the last iteration was finished.
  37512. */
  37513. executeNext(): void;
  37514. /**
  37515. * Break the loop and run the success callback.
  37516. */
  37517. breakLoop(): void;
  37518. /**
  37519. * Create and run an async loop.
  37520. * @param iterations the number of iterations.
  37521. * @param fn the function to run each iteration
  37522. * @param successCallback the callback that will be called upon succesful execution
  37523. * @param offset starting offset.
  37524. * @returns the created async loop object
  37525. */
  37526. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  37527. /**
  37528. * A for-loop that will run a given number of iterations synchronous and the rest async.
  37529. * @param iterations total number of iterations
  37530. * @param syncedIterations number of synchronous iterations in each async iteration.
  37531. * @param fn the function to call each iteration.
  37532. * @param callback a success call back that will be called when iterating stops.
  37533. * @param breakFunction a break condition (optional)
  37534. * @param timeout timeout settings for the setTimeout function. default - 0.
  37535. * @returns the created async loop object
  37536. */
  37537. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  37538. }
  37539. }
  37540. declare module BABYLON {
  37541. /**
  37542. * This class implement a typical dictionary using a string as key and the generic type T as value.
  37543. * The underlying implementation relies on an associative array to ensure the best performances.
  37544. * The value can be anything including 'null' but except 'undefined'
  37545. */
  37546. export class StringDictionary<T> {
  37547. /**
  37548. * This will clear this dictionary and copy the content from the 'source' one.
  37549. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  37550. * @param source the dictionary to take the content from and copy to this dictionary
  37551. */
  37552. copyFrom(source: StringDictionary<T>): void;
  37553. /**
  37554. * Get a value based from its key
  37555. * @param key the given key to get the matching value from
  37556. * @return the value if found, otherwise undefined is returned
  37557. */
  37558. get(key: string): T | undefined;
  37559. /**
  37560. * Get a value from its key or add it if it doesn't exist.
  37561. * This method will ensure you that a given key/data will be present in the dictionary.
  37562. * @param key the given key to get the matching value from
  37563. * @param factory the factory that will create the value if the key is not present in the dictionary.
  37564. * The factory will only be invoked if there's no data for the given key.
  37565. * @return the value corresponding to the key.
  37566. */
  37567. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  37568. /**
  37569. * Get a value from its key if present in the dictionary otherwise add it
  37570. * @param key the key to get the value from
  37571. * @param val if there's no such key/value pair in the dictionary add it with this value
  37572. * @return the value corresponding to the key
  37573. */
  37574. getOrAdd(key: string, val: T): T;
  37575. /**
  37576. * Check if there's a given key in the dictionary
  37577. * @param key the key to check for
  37578. * @return true if the key is present, false otherwise
  37579. */
  37580. contains(key: string): boolean;
  37581. /**
  37582. * Add a new key and its corresponding value
  37583. * @param key the key to add
  37584. * @param value the value corresponding to the key
  37585. * @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
  37586. */
  37587. add(key: string, value: T): boolean;
  37588. /**
  37589. * Update a specific value associated to a key
  37590. * @param key defines the key to use
  37591. * @param value defines the value to store
  37592. * @returns true if the value was updated (or false if the key was not found)
  37593. */
  37594. set(key: string, value: T): boolean;
  37595. /**
  37596. * Get the element of the given key and remove it from the dictionary
  37597. * @param key defines the key to search
  37598. * @returns the value associated with the key or null if not found
  37599. */
  37600. getAndRemove(key: string): Nullable<T>;
  37601. /**
  37602. * Remove a key/value from the dictionary.
  37603. * @param key the key to remove
  37604. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  37605. */
  37606. remove(key: string): boolean;
  37607. /**
  37608. * Clear the whole content of the dictionary
  37609. */
  37610. clear(): void;
  37611. /**
  37612. * Gets the current count
  37613. */
  37614. get count(): number;
  37615. /**
  37616. * Execute a callback on each key/val of the dictionary.
  37617. * Note that you can remove any element in this dictionary in the callback implementation
  37618. * @param callback the callback to execute on a given key/value pair
  37619. */
  37620. forEach(callback: (key: string, val: T) => void): void;
  37621. /**
  37622. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  37623. * If the callback returns null or undefined the method will iterate to the next key/value pair
  37624. * Note that you can remove any element in this dictionary in the callback implementation
  37625. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  37626. * @returns the first item
  37627. */
  37628. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  37629. private _count;
  37630. private _data;
  37631. }
  37632. }
  37633. declare module BABYLON {
  37634. /** @hidden */
  37635. export interface ICollisionCoordinator {
  37636. createCollider(): Collider;
  37637. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  37638. init(scene: Scene): void;
  37639. }
  37640. /** @hidden */
  37641. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  37642. private _scene;
  37643. private _scaledPosition;
  37644. private _scaledVelocity;
  37645. private _finalPosition;
  37646. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  37647. createCollider(): Collider;
  37648. init(scene: Scene): void;
  37649. private _collideWithWorld;
  37650. }
  37651. }
  37652. declare module BABYLON {
  37653. /**
  37654. * Class used to manage all inputs for the scene.
  37655. */
  37656. export class InputManager {
  37657. /** The distance in pixel that you have to move to prevent some events */
  37658. static DragMovementThreshold: number;
  37659. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  37660. static LongPressDelay: number;
  37661. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  37662. static DoubleClickDelay: number;
  37663. /** If you need to check double click without raising a single click at first click, enable this flag */
  37664. static ExclusiveDoubleClickMode: boolean;
  37665. private _wheelEventName;
  37666. private _onPointerMove;
  37667. private _onPointerDown;
  37668. private _onPointerUp;
  37669. private _initClickEvent;
  37670. private _initActionManager;
  37671. private _delayedSimpleClick;
  37672. private _delayedSimpleClickTimeout;
  37673. private _previousDelayedSimpleClickTimeout;
  37674. private _meshPickProceed;
  37675. private _previousButtonPressed;
  37676. private _currentPickResult;
  37677. private _previousPickResult;
  37678. private _totalPointersPressed;
  37679. private _doubleClickOccured;
  37680. private _pointerOverMesh;
  37681. private _pickedDownMesh;
  37682. private _pickedUpMesh;
  37683. private _pointerX;
  37684. private _pointerY;
  37685. private _unTranslatedPointerX;
  37686. private _unTranslatedPointerY;
  37687. private _startingPointerPosition;
  37688. private _previousStartingPointerPosition;
  37689. private _startingPointerTime;
  37690. private _previousStartingPointerTime;
  37691. private _pointerCaptures;
  37692. private _onKeyDown;
  37693. private _onKeyUp;
  37694. private _onCanvasFocusObserver;
  37695. private _onCanvasBlurObserver;
  37696. private _scene;
  37697. /**
  37698. * Creates a new InputManager
  37699. * @param scene defines the hosting scene
  37700. */
  37701. constructor(scene: Scene);
  37702. /**
  37703. * Gets the mesh that is currently under the pointer
  37704. */
  37705. get meshUnderPointer(): Nullable<AbstractMesh>;
  37706. /**
  37707. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  37708. */
  37709. get unTranslatedPointer(): Vector2;
  37710. /**
  37711. * Gets or sets the current on-screen X position of the pointer
  37712. */
  37713. get pointerX(): number;
  37714. set pointerX(value: number);
  37715. /**
  37716. * Gets or sets the current on-screen Y position of the pointer
  37717. */
  37718. get pointerY(): number;
  37719. set pointerY(value: number);
  37720. private _updatePointerPosition;
  37721. private _processPointerMove;
  37722. private _setRayOnPointerInfo;
  37723. private _checkPrePointerObservable;
  37724. /**
  37725. * Use this method to simulate a pointer move on a mesh
  37726. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37727. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37728. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37729. */
  37730. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  37731. /**
  37732. * Use this method to simulate a pointer down on a mesh
  37733. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37734. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37735. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37736. */
  37737. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  37738. private _processPointerDown;
  37739. /** @hidden */
  37740. _isPointerSwiping(): boolean;
  37741. /**
  37742. * Use this method to simulate a pointer up on a mesh
  37743. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37744. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37745. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37746. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37747. */
  37748. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  37749. private _processPointerUp;
  37750. /**
  37751. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37752. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37753. * @returns true if the pointer was captured
  37754. */
  37755. isPointerCaptured(pointerId?: number): boolean;
  37756. /**
  37757. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37758. * @param attachUp defines if you want to attach events to pointerup
  37759. * @param attachDown defines if you want to attach events to pointerdown
  37760. * @param attachMove defines if you want to attach events to pointermove
  37761. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  37762. */
  37763. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  37764. /**
  37765. * Detaches all event handlers
  37766. */
  37767. detachControl(): void;
  37768. /**
  37769. * Force the value of meshUnderPointer
  37770. * @param mesh defines the mesh to use
  37771. */
  37772. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37773. /**
  37774. * Gets the mesh under the pointer
  37775. * @returns a Mesh or null if no mesh is under the pointer
  37776. */
  37777. getPointerOverMesh(): Nullable<AbstractMesh>;
  37778. }
  37779. }
  37780. declare module BABYLON {
  37781. /**
  37782. * This class defines the direct association between an animation and a target
  37783. */
  37784. export class TargetedAnimation {
  37785. /**
  37786. * Animation to perform
  37787. */
  37788. animation: Animation;
  37789. /**
  37790. * Target to animate
  37791. */
  37792. target: any;
  37793. /**
  37794. * Serialize the object
  37795. * @returns the JSON object representing the current entity
  37796. */
  37797. serialize(): any;
  37798. }
  37799. /**
  37800. * Use this class to create coordinated animations on multiple targets
  37801. */
  37802. export class AnimationGroup implements IDisposable {
  37803. /** The name of the animation group */
  37804. name: string;
  37805. private _scene;
  37806. private _targetedAnimations;
  37807. private _animatables;
  37808. private _from;
  37809. private _to;
  37810. private _isStarted;
  37811. private _isPaused;
  37812. private _speedRatio;
  37813. private _loopAnimation;
  37814. private _isAdditive;
  37815. /**
  37816. * Gets or sets the unique id of the node
  37817. */
  37818. uniqueId: number;
  37819. /**
  37820. * This observable will notify when one animation have ended
  37821. */
  37822. onAnimationEndObservable: Observable<TargetedAnimation>;
  37823. /**
  37824. * Observer raised when one animation loops
  37825. */
  37826. onAnimationLoopObservable: Observable<TargetedAnimation>;
  37827. /**
  37828. * Observer raised when all animations have looped
  37829. */
  37830. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  37831. /**
  37832. * This observable will notify when all animations have ended.
  37833. */
  37834. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  37835. /**
  37836. * This observable will notify when all animations have paused.
  37837. */
  37838. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  37839. /**
  37840. * This observable will notify when all animations are playing.
  37841. */
  37842. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  37843. /**
  37844. * Gets the first frame
  37845. */
  37846. get from(): number;
  37847. /**
  37848. * Gets the last frame
  37849. */
  37850. get to(): number;
  37851. /**
  37852. * Define if the animations are started
  37853. */
  37854. get isStarted(): boolean;
  37855. /**
  37856. * Gets a value indicating that the current group is playing
  37857. */
  37858. get isPlaying(): boolean;
  37859. /**
  37860. * Gets or sets the speed ratio to use for all animations
  37861. */
  37862. get speedRatio(): number;
  37863. /**
  37864. * Gets or sets the speed ratio to use for all animations
  37865. */
  37866. set speedRatio(value: number);
  37867. /**
  37868. * Gets or sets if all animations should loop or not
  37869. */
  37870. get loopAnimation(): boolean;
  37871. set loopAnimation(value: boolean);
  37872. /**
  37873. * Gets or sets if all animations should be evaluated additively
  37874. */
  37875. get isAdditive(): boolean;
  37876. set isAdditive(value: boolean);
  37877. /**
  37878. * Gets the targeted animations for this animation group
  37879. */
  37880. get targetedAnimations(): Array<TargetedAnimation>;
  37881. /**
  37882. * returning the list of animatables controlled by this animation group.
  37883. */
  37884. get animatables(): Array<Animatable>;
  37885. /**
  37886. * Instantiates a new Animation Group.
  37887. * This helps managing several animations at once.
  37888. * @see http://doc.babylonjs.com/how_to/group
  37889. * @param name Defines the name of the group
  37890. * @param scene Defines the scene the group belongs to
  37891. */
  37892. constructor(
  37893. /** The name of the animation group */
  37894. name: string, scene?: Nullable<Scene>);
  37895. /**
  37896. * Add an animation (with its target) in the group
  37897. * @param animation defines the animation we want to add
  37898. * @param target defines the target of the animation
  37899. * @returns the TargetedAnimation object
  37900. */
  37901. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  37902. /**
  37903. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  37904. * It can add constant keys at begin or end
  37905. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  37906. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  37907. * @returns the animation group
  37908. */
  37909. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  37910. private _animationLoopCount;
  37911. private _animationLoopFlags;
  37912. private _processLoop;
  37913. /**
  37914. * Start all animations on given targets
  37915. * @param loop defines if animations must loop
  37916. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  37917. * @param from defines the from key (optional)
  37918. * @param to defines the to key (optional)
  37919. * @param isAdditive defines the additive state for the resulting animatables (optional)
  37920. * @returns the current animation group
  37921. */
  37922. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  37923. /**
  37924. * Pause all animations
  37925. * @returns the animation group
  37926. */
  37927. pause(): AnimationGroup;
  37928. /**
  37929. * Play all animations to initial state
  37930. * This function will start() the animations if they were not started or will restart() them if they were paused
  37931. * @param loop defines if animations must loop
  37932. * @returns the animation group
  37933. */
  37934. play(loop?: boolean): AnimationGroup;
  37935. /**
  37936. * Reset all animations to initial state
  37937. * @returns the animation group
  37938. */
  37939. reset(): AnimationGroup;
  37940. /**
  37941. * Restart animations from key 0
  37942. * @returns the animation group
  37943. */
  37944. restart(): AnimationGroup;
  37945. /**
  37946. * Stop all animations
  37947. * @returns the animation group
  37948. */
  37949. stop(): AnimationGroup;
  37950. /**
  37951. * Set animation weight for all animatables
  37952. * @param weight defines the weight to use
  37953. * @return the animationGroup
  37954. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  37955. */
  37956. setWeightForAllAnimatables(weight: number): AnimationGroup;
  37957. /**
  37958. * Synchronize and normalize all animatables with a source animatable
  37959. * @param root defines the root animatable to synchronize with
  37960. * @return the animationGroup
  37961. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  37962. */
  37963. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  37964. /**
  37965. * Goes to a specific frame in this animation group
  37966. * @param frame the frame number to go to
  37967. * @return the animationGroup
  37968. */
  37969. goToFrame(frame: number): AnimationGroup;
  37970. /**
  37971. * Dispose all associated resources
  37972. */
  37973. dispose(): void;
  37974. private _checkAnimationGroupEnded;
  37975. /**
  37976. * Clone the current animation group and returns a copy
  37977. * @param newName defines the name of the new group
  37978. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  37979. * @returns the new aniamtion group
  37980. */
  37981. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  37982. /**
  37983. * Serializes the animationGroup to an object
  37984. * @returns Serialized object
  37985. */
  37986. serialize(): any;
  37987. /**
  37988. * Returns a new AnimationGroup object parsed from the source provided.
  37989. * @param parsedAnimationGroup defines the source
  37990. * @param scene defines the scene that will receive the animationGroup
  37991. * @returns a new AnimationGroup
  37992. */
  37993. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  37994. /**
  37995. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  37996. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  37997. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  37998. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  37999. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  38000. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  38001. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  38002. */
  38003. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  38004. /**
  38005. * Returns the string "AnimationGroup"
  38006. * @returns "AnimationGroup"
  38007. */
  38008. getClassName(): string;
  38009. /**
  38010. * Creates a detailled string about the object
  38011. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  38012. * @returns a string representing the object
  38013. */
  38014. toString(fullDetails?: boolean): string;
  38015. }
  38016. }
  38017. declare module BABYLON {
  38018. /**
  38019. * Define an interface for all classes that will hold resources
  38020. */
  38021. export interface IDisposable {
  38022. /**
  38023. * Releases all held resources
  38024. */
  38025. dispose(): void;
  38026. }
  38027. /** Interface defining initialization parameters for Scene class */
  38028. export interface SceneOptions {
  38029. /**
  38030. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  38031. * It will improve performance when the number of geometries becomes important.
  38032. */
  38033. useGeometryUniqueIdsMap?: boolean;
  38034. /**
  38035. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  38036. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  38037. */
  38038. useMaterialMeshMap?: boolean;
  38039. /**
  38040. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  38041. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  38042. */
  38043. useClonedMeshMap?: boolean;
  38044. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  38045. virtual?: boolean;
  38046. }
  38047. /**
  38048. * Represents a scene to be rendered by the engine.
  38049. * @see http://doc.babylonjs.com/features/scene
  38050. */
  38051. export class Scene extends AbstractScene implements IAnimatable {
  38052. /** The fog is deactivated */
  38053. static readonly FOGMODE_NONE: number;
  38054. /** The fog density is following an exponential function */
  38055. static readonly FOGMODE_EXP: number;
  38056. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  38057. static readonly FOGMODE_EXP2: number;
  38058. /** The fog density is following a linear function. */
  38059. static readonly FOGMODE_LINEAR: number;
  38060. /**
  38061. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  38062. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38063. */
  38064. static MinDeltaTime: number;
  38065. /**
  38066. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  38067. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38068. */
  38069. static MaxDeltaTime: number;
  38070. /**
  38071. * Factory used to create the default material.
  38072. * @param name The name of the material to create
  38073. * @param scene The scene to create the material for
  38074. * @returns The default material
  38075. */
  38076. static DefaultMaterialFactory(scene: Scene): Material;
  38077. /**
  38078. * Factory used to create the a collision coordinator.
  38079. * @returns The collision coordinator
  38080. */
  38081. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  38082. /** @hidden */
  38083. _inputManager: InputManager;
  38084. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  38085. cameraToUseForPointers: Nullable<Camera>;
  38086. /** @hidden */
  38087. readonly _isScene: boolean;
  38088. /** @hidden */
  38089. _blockEntityCollection: boolean;
  38090. /**
  38091. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  38092. */
  38093. autoClear: boolean;
  38094. /**
  38095. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  38096. */
  38097. autoClearDepthAndStencil: boolean;
  38098. /**
  38099. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  38100. */
  38101. clearColor: Color4;
  38102. /**
  38103. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  38104. */
  38105. ambientColor: Color3;
  38106. /**
  38107. * This is use to store the default BRDF lookup for PBR materials in your scene.
  38108. * It should only be one of the following (if not the default embedded one):
  38109. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  38110. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  38111. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  38112. * The material properties need to be setup according to the type of texture in use.
  38113. */
  38114. environmentBRDFTexture: BaseTexture;
  38115. /** @hidden */
  38116. protected _environmentTexture: Nullable<BaseTexture>;
  38117. /**
  38118. * Texture used in all pbr material as the reflection texture.
  38119. * As in the majority of the scene they are the same (exception for multi room and so on),
  38120. * this is easier to reference from here than from all the materials.
  38121. */
  38122. get environmentTexture(): Nullable<BaseTexture>;
  38123. /**
  38124. * Texture used in all pbr material as the reflection texture.
  38125. * As in the majority of the scene they are the same (exception for multi room and so on),
  38126. * this is easier to set here than in all the materials.
  38127. */
  38128. set environmentTexture(value: Nullable<BaseTexture>);
  38129. /** @hidden */
  38130. protected _environmentIntensity: number;
  38131. /**
  38132. * Intensity of the environment in all pbr material.
  38133. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  38134. * As in the majority of the scene they are the same (exception for multi room and so on),
  38135. * this is easier to reference from here than from all the materials.
  38136. */
  38137. get environmentIntensity(): number;
  38138. /**
  38139. * Intensity of the environment in all pbr material.
  38140. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  38141. * As in the majority of the scene they are the same (exception for multi room and so on),
  38142. * this is easier to set here than in all the materials.
  38143. */
  38144. set environmentIntensity(value: number);
  38145. /** @hidden */
  38146. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38147. /**
  38148. * Default image processing configuration used either in the rendering
  38149. * Forward main pass or through the imageProcessingPostProcess if present.
  38150. * As in the majority of the scene they are the same (exception for multi camera),
  38151. * this is easier to reference from here than from all the materials and post process.
  38152. *
  38153. * No setter as we it is a shared configuration, you can set the values instead.
  38154. */
  38155. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  38156. private _forceWireframe;
  38157. /**
  38158. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  38159. */
  38160. set forceWireframe(value: boolean);
  38161. get forceWireframe(): boolean;
  38162. private _skipFrustumClipping;
  38163. /**
  38164. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  38165. */
  38166. set skipFrustumClipping(value: boolean);
  38167. get skipFrustumClipping(): boolean;
  38168. private _forcePointsCloud;
  38169. /**
  38170. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  38171. */
  38172. set forcePointsCloud(value: boolean);
  38173. get forcePointsCloud(): boolean;
  38174. /**
  38175. * Gets or sets the active clipplane 1
  38176. */
  38177. clipPlane: Nullable<Plane>;
  38178. /**
  38179. * Gets or sets the active clipplane 2
  38180. */
  38181. clipPlane2: Nullable<Plane>;
  38182. /**
  38183. * Gets or sets the active clipplane 3
  38184. */
  38185. clipPlane3: Nullable<Plane>;
  38186. /**
  38187. * Gets or sets the active clipplane 4
  38188. */
  38189. clipPlane4: Nullable<Plane>;
  38190. /**
  38191. * Gets or sets the active clipplane 5
  38192. */
  38193. clipPlane5: Nullable<Plane>;
  38194. /**
  38195. * Gets or sets the active clipplane 6
  38196. */
  38197. clipPlane6: Nullable<Plane>;
  38198. /**
  38199. * Gets or sets a boolean indicating if animations are enabled
  38200. */
  38201. animationsEnabled: boolean;
  38202. private _animationPropertiesOverride;
  38203. /**
  38204. * Gets or sets the animation properties override
  38205. */
  38206. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  38207. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  38208. /**
  38209. * Gets or sets a boolean indicating if a constant deltatime has to be used
  38210. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  38211. */
  38212. useConstantAnimationDeltaTime: boolean;
  38213. /**
  38214. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  38215. * Please note that it requires to run a ray cast through the scene on every frame
  38216. */
  38217. constantlyUpdateMeshUnderPointer: boolean;
  38218. /**
  38219. * Defines the HTML cursor to use when hovering over interactive elements
  38220. */
  38221. hoverCursor: string;
  38222. /**
  38223. * Defines the HTML default cursor to use (empty by default)
  38224. */
  38225. defaultCursor: string;
  38226. /**
  38227. * Defines whether cursors are handled by the scene.
  38228. */
  38229. doNotHandleCursors: boolean;
  38230. /**
  38231. * This is used to call preventDefault() on pointer down
  38232. * in order to block unwanted artifacts like system double clicks
  38233. */
  38234. preventDefaultOnPointerDown: boolean;
  38235. /**
  38236. * This is used to call preventDefault() on pointer up
  38237. * in order to block unwanted artifacts like system double clicks
  38238. */
  38239. preventDefaultOnPointerUp: boolean;
  38240. /**
  38241. * Gets or sets user defined metadata
  38242. */
  38243. metadata: any;
  38244. /**
  38245. * For internal use only. Please do not use.
  38246. */
  38247. reservedDataStore: any;
  38248. /**
  38249. * Gets the name of the plugin used to load this scene (null by default)
  38250. */
  38251. loadingPluginName: string;
  38252. /**
  38253. * Use this array to add regular expressions used to disable offline support for specific urls
  38254. */
  38255. disableOfflineSupportExceptionRules: RegExp[];
  38256. /**
  38257. * An event triggered when the scene is disposed.
  38258. */
  38259. onDisposeObservable: Observable<Scene>;
  38260. private _onDisposeObserver;
  38261. /** Sets a function to be executed when this scene is disposed. */
  38262. set onDispose(callback: () => void);
  38263. /**
  38264. * An event triggered before rendering the scene (right after animations and physics)
  38265. */
  38266. onBeforeRenderObservable: Observable<Scene>;
  38267. private _onBeforeRenderObserver;
  38268. /** Sets a function to be executed before rendering this scene */
  38269. set beforeRender(callback: Nullable<() => void>);
  38270. /**
  38271. * An event triggered after rendering the scene
  38272. */
  38273. onAfterRenderObservable: Observable<Scene>;
  38274. /**
  38275. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  38276. */
  38277. onAfterRenderCameraObservable: Observable<Camera>;
  38278. private _onAfterRenderObserver;
  38279. /** Sets a function to be executed after rendering this scene */
  38280. set afterRender(callback: Nullable<() => void>);
  38281. /**
  38282. * An event triggered before animating the scene
  38283. */
  38284. onBeforeAnimationsObservable: Observable<Scene>;
  38285. /**
  38286. * An event triggered after animations processing
  38287. */
  38288. onAfterAnimationsObservable: Observable<Scene>;
  38289. /**
  38290. * An event triggered before draw calls are ready to be sent
  38291. */
  38292. onBeforeDrawPhaseObservable: Observable<Scene>;
  38293. /**
  38294. * An event triggered after draw calls have been sent
  38295. */
  38296. onAfterDrawPhaseObservable: Observable<Scene>;
  38297. /**
  38298. * An event triggered when the scene is ready
  38299. */
  38300. onReadyObservable: Observable<Scene>;
  38301. /**
  38302. * An event triggered before rendering a camera
  38303. */
  38304. onBeforeCameraRenderObservable: Observable<Camera>;
  38305. private _onBeforeCameraRenderObserver;
  38306. /** Sets a function to be executed before rendering a camera*/
  38307. set beforeCameraRender(callback: () => void);
  38308. /**
  38309. * An event triggered after rendering a camera
  38310. */
  38311. onAfterCameraRenderObservable: Observable<Camera>;
  38312. private _onAfterCameraRenderObserver;
  38313. /** Sets a function to be executed after rendering a camera*/
  38314. set afterCameraRender(callback: () => void);
  38315. /**
  38316. * An event triggered when active meshes evaluation is about to start
  38317. */
  38318. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  38319. /**
  38320. * An event triggered when active meshes evaluation is done
  38321. */
  38322. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  38323. /**
  38324. * An event triggered when particles rendering is about to start
  38325. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  38326. */
  38327. onBeforeParticlesRenderingObservable: Observable<Scene>;
  38328. /**
  38329. * An event triggered when particles rendering is done
  38330. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  38331. */
  38332. onAfterParticlesRenderingObservable: Observable<Scene>;
  38333. /**
  38334. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  38335. */
  38336. onDataLoadedObservable: Observable<Scene>;
  38337. /**
  38338. * An event triggered when a camera is created
  38339. */
  38340. onNewCameraAddedObservable: Observable<Camera>;
  38341. /**
  38342. * An event triggered when a camera is removed
  38343. */
  38344. onCameraRemovedObservable: Observable<Camera>;
  38345. /**
  38346. * An event triggered when a light is created
  38347. */
  38348. onNewLightAddedObservable: Observable<Light>;
  38349. /**
  38350. * An event triggered when a light is removed
  38351. */
  38352. onLightRemovedObservable: Observable<Light>;
  38353. /**
  38354. * An event triggered when a geometry is created
  38355. */
  38356. onNewGeometryAddedObservable: Observable<Geometry>;
  38357. /**
  38358. * An event triggered when a geometry is removed
  38359. */
  38360. onGeometryRemovedObservable: Observable<Geometry>;
  38361. /**
  38362. * An event triggered when a transform node is created
  38363. */
  38364. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  38365. /**
  38366. * An event triggered when a transform node is removed
  38367. */
  38368. onTransformNodeRemovedObservable: Observable<TransformNode>;
  38369. /**
  38370. * An event triggered when a mesh is created
  38371. */
  38372. onNewMeshAddedObservable: Observable<AbstractMesh>;
  38373. /**
  38374. * An event triggered when a mesh is removed
  38375. */
  38376. onMeshRemovedObservable: Observable<AbstractMesh>;
  38377. /**
  38378. * An event triggered when a skeleton is created
  38379. */
  38380. onNewSkeletonAddedObservable: Observable<Skeleton>;
  38381. /**
  38382. * An event triggered when a skeleton is removed
  38383. */
  38384. onSkeletonRemovedObservable: Observable<Skeleton>;
  38385. /**
  38386. * An event triggered when a material is created
  38387. */
  38388. onNewMaterialAddedObservable: Observable<Material>;
  38389. /**
  38390. * An event triggered when a material is removed
  38391. */
  38392. onMaterialRemovedObservable: Observable<Material>;
  38393. /**
  38394. * An event triggered when a texture is created
  38395. */
  38396. onNewTextureAddedObservable: Observable<BaseTexture>;
  38397. /**
  38398. * An event triggered when a texture is removed
  38399. */
  38400. onTextureRemovedObservable: Observable<BaseTexture>;
  38401. /**
  38402. * An event triggered when render targets are about to be rendered
  38403. * Can happen multiple times per frame.
  38404. */
  38405. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  38406. /**
  38407. * An event triggered when render targets were rendered.
  38408. * Can happen multiple times per frame.
  38409. */
  38410. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  38411. /**
  38412. * An event triggered before calculating deterministic simulation step
  38413. */
  38414. onBeforeStepObservable: Observable<Scene>;
  38415. /**
  38416. * An event triggered after calculating deterministic simulation step
  38417. */
  38418. onAfterStepObservable: Observable<Scene>;
  38419. /**
  38420. * An event triggered when the activeCamera property is updated
  38421. */
  38422. onActiveCameraChanged: Observable<Scene>;
  38423. /**
  38424. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  38425. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  38426. * 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)
  38427. */
  38428. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38429. /**
  38430. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  38431. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  38432. * 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)
  38433. */
  38434. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38435. /**
  38436. * This Observable will when a mesh has been imported into the scene.
  38437. */
  38438. onMeshImportedObservable: Observable<AbstractMesh>;
  38439. /**
  38440. * This Observable will when an animation file has been imported into the scene.
  38441. */
  38442. onAnimationFileImportedObservable: Observable<Scene>;
  38443. /**
  38444. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  38445. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  38446. */
  38447. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  38448. /** @hidden */
  38449. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  38450. /**
  38451. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  38452. */
  38453. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  38454. /**
  38455. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  38456. */
  38457. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  38458. /**
  38459. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  38460. */
  38461. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  38462. /** Callback called when a pointer move is detected */
  38463. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38464. /** Callback called when a pointer down is detected */
  38465. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38466. /** Callback called when a pointer up is detected */
  38467. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  38468. /** Callback called when a pointer pick is detected */
  38469. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  38470. /**
  38471. * 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).
  38472. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  38473. */
  38474. onPrePointerObservable: Observable<PointerInfoPre>;
  38475. /**
  38476. * Observable event triggered each time an input event is received from the rendering canvas
  38477. */
  38478. onPointerObservable: Observable<PointerInfo>;
  38479. /**
  38480. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  38481. */
  38482. get unTranslatedPointer(): Vector2;
  38483. /**
  38484. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  38485. */
  38486. static get DragMovementThreshold(): number;
  38487. static set DragMovementThreshold(value: number);
  38488. /**
  38489. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  38490. */
  38491. static get LongPressDelay(): number;
  38492. static set LongPressDelay(value: number);
  38493. /**
  38494. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  38495. */
  38496. static get DoubleClickDelay(): number;
  38497. static set DoubleClickDelay(value: number);
  38498. /** If you need to check double click without raising a single click at first click, enable this flag */
  38499. static get ExclusiveDoubleClickMode(): boolean;
  38500. static set ExclusiveDoubleClickMode(value: boolean);
  38501. /** @hidden */
  38502. _mirroredCameraPosition: Nullable<Vector3>;
  38503. /**
  38504. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  38505. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  38506. */
  38507. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  38508. /**
  38509. * Observable event triggered each time an keyboard event is received from the hosting window
  38510. */
  38511. onKeyboardObservable: Observable<KeyboardInfo>;
  38512. private _useRightHandedSystem;
  38513. /**
  38514. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  38515. */
  38516. set useRightHandedSystem(value: boolean);
  38517. get useRightHandedSystem(): boolean;
  38518. private _timeAccumulator;
  38519. private _currentStepId;
  38520. private _currentInternalStep;
  38521. /**
  38522. * Sets the step Id used by deterministic lock step
  38523. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38524. * @param newStepId defines the step Id
  38525. */
  38526. setStepId(newStepId: number): void;
  38527. /**
  38528. * Gets the step Id used by deterministic lock step
  38529. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38530. * @returns the step Id
  38531. */
  38532. getStepId(): number;
  38533. /**
  38534. * Gets the internal step used by deterministic lock step
  38535. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38536. * @returns the internal step
  38537. */
  38538. getInternalStep(): number;
  38539. private _fogEnabled;
  38540. /**
  38541. * Gets or sets a boolean indicating if fog is enabled on this scene
  38542. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38543. * (Default is true)
  38544. */
  38545. set fogEnabled(value: boolean);
  38546. get fogEnabled(): boolean;
  38547. private _fogMode;
  38548. /**
  38549. * Gets or sets the fog mode to use
  38550. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38551. * | mode | value |
  38552. * | --- | --- |
  38553. * | FOGMODE_NONE | 0 |
  38554. * | FOGMODE_EXP | 1 |
  38555. * | FOGMODE_EXP2 | 2 |
  38556. * | FOGMODE_LINEAR | 3 |
  38557. */
  38558. set fogMode(value: number);
  38559. get fogMode(): number;
  38560. /**
  38561. * Gets or sets the fog color to use
  38562. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38563. * (Default is Color3(0.2, 0.2, 0.3))
  38564. */
  38565. fogColor: Color3;
  38566. /**
  38567. * Gets or sets the fog density to use
  38568. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38569. * (Default is 0.1)
  38570. */
  38571. fogDensity: number;
  38572. /**
  38573. * Gets or sets the fog start distance to use
  38574. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38575. * (Default is 0)
  38576. */
  38577. fogStart: number;
  38578. /**
  38579. * Gets or sets the fog end distance to use
  38580. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38581. * (Default is 1000)
  38582. */
  38583. fogEnd: number;
  38584. private _shadowsEnabled;
  38585. /**
  38586. * Gets or sets a boolean indicating if shadows are enabled on this scene
  38587. */
  38588. set shadowsEnabled(value: boolean);
  38589. get shadowsEnabled(): boolean;
  38590. private _lightsEnabled;
  38591. /**
  38592. * Gets or sets a boolean indicating if lights are enabled on this scene
  38593. */
  38594. set lightsEnabled(value: boolean);
  38595. get lightsEnabled(): boolean;
  38596. /** All of the active cameras added to this scene. */
  38597. activeCameras: Camera[];
  38598. /** @hidden */
  38599. _activeCamera: Nullable<Camera>;
  38600. /** Gets or sets the current active camera */
  38601. get activeCamera(): Nullable<Camera>;
  38602. set activeCamera(value: Nullable<Camera>);
  38603. private _defaultMaterial;
  38604. /** The default material used on meshes when no material is affected */
  38605. get defaultMaterial(): Material;
  38606. /** The default material used on meshes when no material is affected */
  38607. set defaultMaterial(value: Material);
  38608. private _texturesEnabled;
  38609. /**
  38610. * Gets or sets a boolean indicating if textures are enabled on this scene
  38611. */
  38612. set texturesEnabled(value: boolean);
  38613. get texturesEnabled(): boolean;
  38614. /**
  38615. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  38616. */
  38617. physicsEnabled: boolean;
  38618. /**
  38619. * Gets or sets a boolean indicating if particles are enabled on this scene
  38620. */
  38621. particlesEnabled: boolean;
  38622. /**
  38623. * Gets or sets a boolean indicating if sprites are enabled on this scene
  38624. */
  38625. spritesEnabled: boolean;
  38626. private _skeletonsEnabled;
  38627. /**
  38628. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  38629. */
  38630. set skeletonsEnabled(value: boolean);
  38631. get skeletonsEnabled(): boolean;
  38632. /**
  38633. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  38634. */
  38635. lensFlaresEnabled: boolean;
  38636. /**
  38637. * Gets or sets a boolean indicating if collisions are enabled on this scene
  38638. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38639. */
  38640. collisionsEnabled: boolean;
  38641. private _collisionCoordinator;
  38642. /** @hidden */
  38643. get collisionCoordinator(): ICollisionCoordinator;
  38644. /**
  38645. * Defines the gravity applied to this scene (used only for collisions)
  38646. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38647. */
  38648. gravity: Vector3;
  38649. /**
  38650. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  38651. */
  38652. postProcessesEnabled: boolean;
  38653. /**
  38654. * The list of postprocesses added to the scene
  38655. */
  38656. postProcesses: PostProcess[];
  38657. /**
  38658. * Gets the current postprocess manager
  38659. */
  38660. postProcessManager: PostProcessManager;
  38661. /**
  38662. * Gets or sets a boolean indicating if render targets are enabled on this scene
  38663. */
  38664. renderTargetsEnabled: boolean;
  38665. /**
  38666. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  38667. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  38668. */
  38669. dumpNextRenderTargets: boolean;
  38670. /**
  38671. * The list of user defined render targets added to the scene
  38672. */
  38673. customRenderTargets: RenderTargetTexture[];
  38674. /**
  38675. * Defines if texture loading must be delayed
  38676. * If true, textures will only be loaded when they need to be rendered
  38677. */
  38678. useDelayedTextureLoading: boolean;
  38679. /**
  38680. * Gets the list of meshes imported to the scene through SceneLoader
  38681. */
  38682. importedMeshesFiles: String[];
  38683. /**
  38684. * Gets or sets a boolean indicating if probes are enabled on this scene
  38685. */
  38686. probesEnabled: boolean;
  38687. /**
  38688. * Gets or sets the current offline provider to use to store scene data
  38689. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  38690. */
  38691. offlineProvider: IOfflineProvider;
  38692. /**
  38693. * Gets or sets the action manager associated with the scene
  38694. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38695. */
  38696. actionManager: AbstractActionManager;
  38697. private _meshesForIntersections;
  38698. /**
  38699. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  38700. */
  38701. proceduralTexturesEnabled: boolean;
  38702. private _engine;
  38703. private _totalVertices;
  38704. /** @hidden */
  38705. _activeIndices: PerfCounter;
  38706. /** @hidden */
  38707. _activeParticles: PerfCounter;
  38708. /** @hidden */
  38709. _activeBones: PerfCounter;
  38710. private _animationRatio;
  38711. /** @hidden */
  38712. _animationTimeLast: number;
  38713. /** @hidden */
  38714. _animationTime: number;
  38715. /**
  38716. * Gets or sets a general scale for animation speed
  38717. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  38718. */
  38719. animationTimeScale: number;
  38720. /** @hidden */
  38721. _cachedMaterial: Nullable<Material>;
  38722. /** @hidden */
  38723. _cachedEffect: Nullable<Effect>;
  38724. /** @hidden */
  38725. _cachedVisibility: Nullable<number>;
  38726. private _renderId;
  38727. private _frameId;
  38728. private _executeWhenReadyTimeoutId;
  38729. private _intermediateRendering;
  38730. private _viewUpdateFlag;
  38731. private _projectionUpdateFlag;
  38732. /** @hidden */
  38733. _toBeDisposed: Nullable<IDisposable>[];
  38734. private _activeRequests;
  38735. /** @hidden */
  38736. _pendingData: any[];
  38737. private _isDisposed;
  38738. /**
  38739. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  38740. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  38741. */
  38742. dispatchAllSubMeshesOfActiveMeshes: boolean;
  38743. private _activeMeshes;
  38744. private _processedMaterials;
  38745. private _renderTargets;
  38746. /** @hidden */
  38747. _activeParticleSystems: SmartArray<IParticleSystem>;
  38748. private _activeSkeletons;
  38749. private _softwareSkinnedMeshes;
  38750. private _renderingManager;
  38751. /** @hidden */
  38752. _activeAnimatables: Animatable[];
  38753. private _transformMatrix;
  38754. private _sceneUbo;
  38755. /** @hidden */
  38756. _viewMatrix: Matrix;
  38757. private _projectionMatrix;
  38758. /** @hidden */
  38759. _forcedViewPosition: Nullable<Vector3>;
  38760. /** @hidden */
  38761. _frustumPlanes: Plane[];
  38762. /**
  38763. * Gets the list of frustum planes (built from the active camera)
  38764. */
  38765. get frustumPlanes(): Plane[];
  38766. /**
  38767. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  38768. * This is useful if there are more lights that the maximum simulteanous authorized
  38769. */
  38770. requireLightSorting: boolean;
  38771. /** @hidden */
  38772. readonly useMaterialMeshMap: boolean;
  38773. /** @hidden */
  38774. readonly useClonedMeshMap: boolean;
  38775. private _externalData;
  38776. private _uid;
  38777. /**
  38778. * @hidden
  38779. * Backing store of defined scene components.
  38780. */
  38781. _components: ISceneComponent[];
  38782. /**
  38783. * @hidden
  38784. * Backing store of defined scene components.
  38785. */
  38786. _serializableComponents: ISceneSerializableComponent[];
  38787. /**
  38788. * List of components to register on the next registration step.
  38789. */
  38790. private _transientComponents;
  38791. /**
  38792. * Registers the transient components if needed.
  38793. */
  38794. private _registerTransientComponents;
  38795. /**
  38796. * @hidden
  38797. * Add a component to the scene.
  38798. * Note that the ccomponent could be registered on th next frame if this is called after
  38799. * the register component stage.
  38800. * @param component Defines the component to add to the scene
  38801. */
  38802. _addComponent(component: ISceneComponent): void;
  38803. /**
  38804. * @hidden
  38805. * Gets a component from the scene.
  38806. * @param name defines the name of the component to retrieve
  38807. * @returns the component or null if not present
  38808. */
  38809. _getComponent(name: string): Nullable<ISceneComponent>;
  38810. /**
  38811. * @hidden
  38812. * Defines the actions happening before camera updates.
  38813. */
  38814. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  38815. /**
  38816. * @hidden
  38817. * Defines the actions happening before clear the canvas.
  38818. */
  38819. _beforeClearStage: Stage<SimpleStageAction>;
  38820. /**
  38821. * @hidden
  38822. * Defines the actions when collecting render targets for the frame.
  38823. */
  38824. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  38825. /**
  38826. * @hidden
  38827. * Defines the actions happening for one camera in the frame.
  38828. */
  38829. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  38830. /**
  38831. * @hidden
  38832. * Defines the actions happening during the per mesh ready checks.
  38833. */
  38834. _isReadyForMeshStage: Stage<MeshStageAction>;
  38835. /**
  38836. * @hidden
  38837. * Defines the actions happening before evaluate active mesh checks.
  38838. */
  38839. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  38840. /**
  38841. * @hidden
  38842. * Defines the actions happening during the evaluate sub mesh checks.
  38843. */
  38844. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  38845. /**
  38846. * @hidden
  38847. * Defines the actions happening during the active mesh stage.
  38848. */
  38849. _activeMeshStage: Stage<ActiveMeshStageAction>;
  38850. /**
  38851. * @hidden
  38852. * Defines the actions happening during the per camera render target step.
  38853. */
  38854. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  38855. /**
  38856. * @hidden
  38857. * Defines the actions happening just before the active camera is drawing.
  38858. */
  38859. _beforeCameraDrawStage: Stage<CameraStageAction>;
  38860. /**
  38861. * @hidden
  38862. * Defines the actions happening just before a render target is drawing.
  38863. */
  38864. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  38865. /**
  38866. * @hidden
  38867. * Defines the actions happening just before a rendering group is drawing.
  38868. */
  38869. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  38870. /**
  38871. * @hidden
  38872. * Defines the actions happening just before a mesh is drawing.
  38873. */
  38874. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  38875. /**
  38876. * @hidden
  38877. * Defines the actions happening just after a mesh has been drawn.
  38878. */
  38879. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  38880. /**
  38881. * @hidden
  38882. * Defines the actions happening just after a rendering group has been drawn.
  38883. */
  38884. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  38885. /**
  38886. * @hidden
  38887. * Defines the actions happening just after the active camera has been drawn.
  38888. */
  38889. _afterCameraDrawStage: Stage<CameraStageAction>;
  38890. /**
  38891. * @hidden
  38892. * Defines the actions happening just after a render target has been drawn.
  38893. */
  38894. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  38895. /**
  38896. * @hidden
  38897. * Defines the actions happening just after rendering all cameras and computing intersections.
  38898. */
  38899. _afterRenderStage: Stage<SimpleStageAction>;
  38900. /**
  38901. * @hidden
  38902. * Defines the actions happening when a pointer move event happens.
  38903. */
  38904. _pointerMoveStage: Stage<PointerMoveStageAction>;
  38905. /**
  38906. * @hidden
  38907. * Defines the actions happening when a pointer down event happens.
  38908. */
  38909. _pointerDownStage: Stage<PointerUpDownStageAction>;
  38910. /**
  38911. * @hidden
  38912. * Defines the actions happening when a pointer up event happens.
  38913. */
  38914. _pointerUpStage: Stage<PointerUpDownStageAction>;
  38915. /**
  38916. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  38917. */
  38918. private geometriesByUniqueId;
  38919. /**
  38920. * Creates a new Scene
  38921. * @param engine defines the engine to use to render this scene
  38922. * @param options defines the scene options
  38923. */
  38924. constructor(engine: Engine, options?: SceneOptions);
  38925. /**
  38926. * Gets a string idenfifying the name of the class
  38927. * @returns "Scene" string
  38928. */
  38929. getClassName(): string;
  38930. private _defaultMeshCandidates;
  38931. /**
  38932. * @hidden
  38933. */
  38934. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  38935. private _defaultSubMeshCandidates;
  38936. /**
  38937. * @hidden
  38938. */
  38939. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  38940. /**
  38941. * Sets the default candidate providers for the scene.
  38942. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  38943. * and getCollidingSubMeshCandidates to their default function
  38944. */
  38945. setDefaultCandidateProviders(): void;
  38946. /**
  38947. * Gets the mesh that is currently under the pointer
  38948. */
  38949. get meshUnderPointer(): Nullable<AbstractMesh>;
  38950. /**
  38951. * Gets or sets the current on-screen X position of the pointer
  38952. */
  38953. get pointerX(): number;
  38954. set pointerX(value: number);
  38955. /**
  38956. * Gets or sets the current on-screen Y position of the pointer
  38957. */
  38958. get pointerY(): number;
  38959. set pointerY(value: number);
  38960. /**
  38961. * Gets the cached material (ie. the latest rendered one)
  38962. * @returns the cached material
  38963. */
  38964. getCachedMaterial(): Nullable<Material>;
  38965. /**
  38966. * Gets the cached effect (ie. the latest rendered one)
  38967. * @returns the cached effect
  38968. */
  38969. getCachedEffect(): Nullable<Effect>;
  38970. /**
  38971. * Gets the cached visibility state (ie. the latest rendered one)
  38972. * @returns the cached visibility state
  38973. */
  38974. getCachedVisibility(): Nullable<number>;
  38975. /**
  38976. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  38977. * @param material defines the current material
  38978. * @param effect defines the current effect
  38979. * @param visibility defines the current visibility state
  38980. * @returns true if one parameter is not cached
  38981. */
  38982. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  38983. /**
  38984. * Gets the engine associated with the scene
  38985. * @returns an Engine
  38986. */
  38987. getEngine(): Engine;
  38988. /**
  38989. * Gets the total number of vertices rendered per frame
  38990. * @returns the total number of vertices rendered per frame
  38991. */
  38992. getTotalVertices(): number;
  38993. /**
  38994. * Gets the performance counter for total vertices
  38995. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  38996. */
  38997. get totalVerticesPerfCounter(): PerfCounter;
  38998. /**
  38999. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  39000. * @returns the total number of active indices rendered per frame
  39001. */
  39002. getActiveIndices(): number;
  39003. /**
  39004. * Gets the performance counter for active indices
  39005. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39006. */
  39007. get totalActiveIndicesPerfCounter(): PerfCounter;
  39008. /**
  39009. * Gets the total number of active particles rendered per frame
  39010. * @returns the total number of active particles rendered per frame
  39011. */
  39012. getActiveParticles(): number;
  39013. /**
  39014. * Gets the performance counter for active particles
  39015. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39016. */
  39017. get activeParticlesPerfCounter(): PerfCounter;
  39018. /**
  39019. * Gets the total number of active bones rendered per frame
  39020. * @returns the total number of active bones rendered per frame
  39021. */
  39022. getActiveBones(): number;
  39023. /**
  39024. * Gets the performance counter for active bones
  39025. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39026. */
  39027. get activeBonesPerfCounter(): PerfCounter;
  39028. /**
  39029. * Gets the array of active meshes
  39030. * @returns an array of AbstractMesh
  39031. */
  39032. getActiveMeshes(): SmartArray<AbstractMesh>;
  39033. /**
  39034. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  39035. * @returns a number
  39036. */
  39037. getAnimationRatio(): number;
  39038. /**
  39039. * Gets an unique Id for the current render phase
  39040. * @returns a number
  39041. */
  39042. getRenderId(): number;
  39043. /**
  39044. * Gets an unique Id for the current frame
  39045. * @returns a number
  39046. */
  39047. getFrameId(): number;
  39048. /** Call this function if you want to manually increment the render Id*/
  39049. incrementRenderId(): void;
  39050. private _createUbo;
  39051. /**
  39052. * Use this method to simulate a pointer move on a mesh
  39053. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39054. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39055. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39056. * @returns the current scene
  39057. */
  39058. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39059. /**
  39060. * Use this method to simulate a pointer down on a mesh
  39061. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39062. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39063. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39064. * @returns the current scene
  39065. */
  39066. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39067. /**
  39068. * Use this method to simulate a pointer up on a mesh
  39069. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39070. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39071. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39072. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39073. * @returns the current scene
  39074. */
  39075. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  39076. /**
  39077. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39078. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39079. * @returns true if the pointer was captured
  39080. */
  39081. isPointerCaptured(pointerId?: number): boolean;
  39082. /**
  39083. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39084. * @param attachUp defines if you want to attach events to pointerup
  39085. * @param attachDown defines if you want to attach events to pointerdown
  39086. * @param attachMove defines if you want to attach events to pointermove
  39087. */
  39088. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  39089. /** Detaches all event handlers*/
  39090. detachControl(): void;
  39091. /**
  39092. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  39093. * Delay loaded resources are not taking in account
  39094. * @return true if all required resources are ready
  39095. */
  39096. isReady(): boolean;
  39097. /** Resets all cached information relative to material (including effect and visibility) */
  39098. resetCachedMaterial(): void;
  39099. /**
  39100. * Registers a function to be called before every frame render
  39101. * @param func defines the function to register
  39102. */
  39103. registerBeforeRender(func: () => void): void;
  39104. /**
  39105. * Unregisters a function called before every frame render
  39106. * @param func defines the function to unregister
  39107. */
  39108. unregisterBeforeRender(func: () => void): void;
  39109. /**
  39110. * Registers a function to be called after every frame render
  39111. * @param func defines the function to register
  39112. */
  39113. registerAfterRender(func: () => void): void;
  39114. /**
  39115. * Unregisters a function called after every frame render
  39116. * @param func defines the function to unregister
  39117. */
  39118. unregisterAfterRender(func: () => void): void;
  39119. private _executeOnceBeforeRender;
  39120. /**
  39121. * The provided function will run before render once and will be disposed afterwards.
  39122. * A timeout delay can be provided so that the function will be executed in N ms.
  39123. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  39124. * @param func The function to be executed.
  39125. * @param timeout optional delay in ms
  39126. */
  39127. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  39128. /** @hidden */
  39129. _addPendingData(data: any): void;
  39130. /** @hidden */
  39131. _removePendingData(data: any): void;
  39132. /**
  39133. * Returns the number of items waiting to be loaded
  39134. * @returns the number of items waiting to be loaded
  39135. */
  39136. getWaitingItemsCount(): number;
  39137. /**
  39138. * Returns a boolean indicating if the scene is still loading data
  39139. */
  39140. get isLoading(): boolean;
  39141. /**
  39142. * Registers a function to be executed when the scene is ready
  39143. * @param {Function} func - the function to be executed
  39144. */
  39145. executeWhenReady(func: () => void): void;
  39146. /**
  39147. * Returns a promise that resolves when the scene is ready
  39148. * @returns A promise that resolves when the scene is ready
  39149. */
  39150. whenReadyAsync(): Promise<void>;
  39151. /** @hidden */
  39152. _checkIsReady(): void;
  39153. /**
  39154. * Gets all animatable attached to the scene
  39155. */
  39156. get animatables(): Animatable[];
  39157. /**
  39158. * Resets the last animation time frame.
  39159. * Useful to override when animations start running when loading a scene for the first time.
  39160. */
  39161. resetLastAnimationTimeFrame(): void;
  39162. /**
  39163. * Gets the current view matrix
  39164. * @returns a Matrix
  39165. */
  39166. getViewMatrix(): Matrix;
  39167. /**
  39168. * Gets the current projection matrix
  39169. * @returns a Matrix
  39170. */
  39171. getProjectionMatrix(): Matrix;
  39172. /**
  39173. * Gets the current transform matrix
  39174. * @returns a Matrix made of View * Projection
  39175. */
  39176. getTransformMatrix(): Matrix;
  39177. /**
  39178. * Sets the current transform matrix
  39179. * @param viewL defines the View matrix to use
  39180. * @param projectionL defines the Projection matrix to use
  39181. * @param viewR defines the right View matrix to use (if provided)
  39182. * @param projectionR defines the right Projection matrix to use (if provided)
  39183. */
  39184. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  39185. /**
  39186. * Gets the uniform buffer used to store scene data
  39187. * @returns a UniformBuffer
  39188. */
  39189. getSceneUniformBuffer(): UniformBuffer;
  39190. /**
  39191. * Gets an unique (relatively to the current scene) Id
  39192. * @returns an unique number for the scene
  39193. */
  39194. getUniqueId(): number;
  39195. /**
  39196. * Add a mesh to the list of scene's meshes
  39197. * @param newMesh defines the mesh to add
  39198. * @param recursive if all child meshes should also be added to the scene
  39199. */
  39200. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  39201. /**
  39202. * Remove a mesh for the list of scene's meshes
  39203. * @param toRemove defines the mesh to remove
  39204. * @param recursive if all child meshes should also be removed from the scene
  39205. * @returns the index where the mesh was in the mesh list
  39206. */
  39207. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  39208. /**
  39209. * Add a transform node to the list of scene's transform nodes
  39210. * @param newTransformNode defines the transform node to add
  39211. */
  39212. addTransformNode(newTransformNode: TransformNode): void;
  39213. /**
  39214. * Remove a transform node for the list of scene's transform nodes
  39215. * @param toRemove defines the transform node to remove
  39216. * @returns the index where the transform node was in the transform node list
  39217. */
  39218. removeTransformNode(toRemove: TransformNode): number;
  39219. /**
  39220. * Remove a skeleton for the list of scene's skeletons
  39221. * @param toRemove defines the skeleton to remove
  39222. * @returns the index where the skeleton was in the skeleton list
  39223. */
  39224. removeSkeleton(toRemove: Skeleton): number;
  39225. /**
  39226. * Remove a morph target for the list of scene's morph targets
  39227. * @param toRemove defines the morph target to remove
  39228. * @returns the index where the morph target was in the morph target list
  39229. */
  39230. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  39231. /**
  39232. * Remove a light for the list of scene's lights
  39233. * @param toRemove defines the light to remove
  39234. * @returns the index where the light was in the light list
  39235. */
  39236. removeLight(toRemove: Light): number;
  39237. /**
  39238. * Remove a camera for the list of scene's cameras
  39239. * @param toRemove defines the camera to remove
  39240. * @returns the index where the camera was in the camera list
  39241. */
  39242. removeCamera(toRemove: Camera): number;
  39243. /**
  39244. * Remove a particle system for the list of scene's particle systems
  39245. * @param toRemove defines the particle system to remove
  39246. * @returns the index where the particle system was in the particle system list
  39247. */
  39248. removeParticleSystem(toRemove: IParticleSystem): number;
  39249. /**
  39250. * Remove a animation for the list of scene's animations
  39251. * @param toRemove defines the animation to remove
  39252. * @returns the index where the animation was in the animation list
  39253. */
  39254. removeAnimation(toRemove: Animation): number;
  39255. /**
  39256. * Will stop the animation of the given target
  39257. * @param target - the target
  39258. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  39259. * @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)
  39260. */
  39261. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  39262. /**
  39263. * Removes the given animation group from this scene.
  39264. * @param toRemove The animation group to remove
  39265. * @returns The index of the removed animation group
  39266. */
  39267. removeAnimationGroup(toRemove: AnimationGroup): number;
  39268. /**
  39269. * Removes the given multi-material from this scene.
  39270. * @param toRemove The multi-material to remove
  39271. * @returns The index of the removed multi-material
  39272. */
  39273. removeMultiMaterial(toRemove: MultiMaterial): number;
  39274. /**
  39275. * Removes the given material from this scene.
  39276. * @param toRemove The material to remove
  39277. * @returns The index of the removed material
  39278. */
  39279. removeMaterial(toRemove: Material): number;
  39280. /**
  39281. * Removes the given action manager from this scene.
  39282. * @param toRemove The action manager to remove
  39283. * @returns The index of the removed action manager
  39284. */
  39285. removeActionManager(toRemove: AbstractActionManager): number;
  39286. /**
  39287. * Removes the given texture from this scene.
  39288. * @param toRemove The texture to remove
  39289. * @returns The index of the removed texture
  39290. */
  39291. removeTexture(toRemove: BaseTexture): number;
  39292. /**
  39293. * Adds the given light to this scene
  39294. * @param newLight The light to add
  39295. */
  39296. addLight(newLight: Light): void;
  39297. /**
  39298. * Sorts the list list based on light priorities
  39299. */
  39300. sortLightsByPriority(): void;
  39301. /**
  39302. * Adds the given camera to this scene
  39303. * @param newCamera The camera to add
  39304. */
  39305. addCamera(newCamera: Camera): void;
  39306. /**
  39307. * Adds the given skeleton to this scene
  39308. * @param newSkeleton The skeleton to add
  39309. */
  39310. addSkeleton(newSkeleton: Skeleton): void;
  39311. /**
  39312. * Adds the given particle system to this scene
  39313. * @param newParticleSystem The particle system to add
  39314. */
  39315. addParticleSystem(newParticleSystem: IParticleSystem): void;
  39316. /**
  39317. * Adds the given animation to this scene
  39318. * @param newAnimation The animation to add
  39319. */
  39320. addAnimation(newAnimation: Animation): void;
  39321. /**
  39322. * Adds the given animation group to this scene.
  39323. * @param newAnimationGroup The animation group to add
  39324. */
  39325. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  39326. /**
  39327. * Adds the given multi-material to this scene
  39328. * @param newMultiMaterial The multi-material to add
  39329. */
  39330. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  39331. /**
  39332. * Adds the given material to this scene
  39333. * @param newMaterial The material to add
  39334. */
  39335. addMaterial(newMaterial: Material): void;
  39336. /**
  39337. * Adds the given morph target to this scene
  39338. * @param newMorphTargetManager The morph target to add
  39339. */
  39340. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  39341. /**
  39342. * Adds the given geometry to this scene
  39343. * @param newGeometry The geometry to add
  39344. */
  39345. addGeometry(newGeometry: Geometry): void;
  39346. /**
  39347. * Adds the given action manager to this scene
  39348. * @param newActionManager The action manager to add
  39349. */
  39350. addActionManager(newActionManager: AbstractActionManager): void;
  39351. /**
  39352. * Adds the given texture to this scene.
  39353. * @param newTexture The texture to add
  39354. */
  39355. addTexture(newTexture: BaseTexture): void;
  39356. /**
  39357. * Switch active camera
  39358. * @param newCamera defines the new active camera
  39359. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  39360. */
  39361. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  39362. /**
  39363. * sets the active camera of the scene using its ID
  39364. * @param id defines the camera's ID
  39365. * @return the new active camera or null if none found.
  39366. */
  39367. setActiveCameraByID(id: string): Nullable<Camera>;
  39368. /**
  39369. * sets the active camera of the scene using its name
  39370. * @param name defines the camera's name
  39371. * @returns the new active camera or null if none found.
  39372. */
  39373. setActiveCameraByName(name: string): Nullable<Camera>;
  39374. /**
  39375. * get an animation group using its name
  39376. * @param name defines the material's name
  39377. * @return the animation group or null if none found.
  39378. */
  39379. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  39380. /**
  39381. * Get a material using its unique id
  39382. * @param uniqueId defines the material's unique id
  39383. * @return the material or null if none found.
  39384. */
  39385. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  39386. /**
  39387. * get a material using its id
  39388. * @param id defines the material's ID
  39389. * @return the material or null if none found.
  39390. */
  39391. getMaterialByID(id: string): Nullable<Material>;
  39392. /**
  39393. * Gets a the last added material using a given id
  39394. * @param id defines the material's ID
  39395. * @return the last material with the given id or null if none found.
  39396. */
  39397. getLastMaterialByID(id: string): Nullable<Material>;
  39398. /**
  39399. * Gets a material using its name
  39400. * @param name defines the material's name
  39401. * @return the material or null if none found.
  39402. */
  39403. getMaterialByName(name: string): Nullable<Material>;
  39404. /**
  39405. * Get a texture using its unique id
  39406. * @param uniqueId defines the texture's unique id
  39407. * @return the texture or null if none found.
  39408. */
  39409. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  39410. /**
  39411. * Gets a camera using its id
  39412. * @param id defines the id to look for
  39413. * @returns the camera or null if not found
  39414. */
  39415. getCameraByID(id: string): Nullable<Camera>;
  39416. /**
  39417. * Gets a camera using its unique id
  39418. * @param uniqueId defines the unique id to look for
  39419. * @returns the camera or null if not found
  39420. */
  39421. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  39422. /**
  39423. * Gets a camera using its name
  39424. * @param name defines the camera's name
  39425. * @return the camera or null if none found.
  39426. */
  39427. getCameraByName(name: string): Nullable<Camera>;
  39428. /**
  39429. * Gets a bone using its id
  39430. * @param id defines the bone's id
  39431. * @return the bone or null if not found
  39432. */
  39433. getBoneByID(id: string): Nullable<Bone>;
  39434. /**
  39435. * Gets a bone using its id
  39436. * @param name defines the bone's name
  39437. * @return the bone or null if not found
  39438. */
  39439. getBoneByName(name: string): Nullable<Bone>;
  39440. /**
  39441. * Gets a light node using its name
  39442. * @param name defines the the light's name
  39443. * @return the light or null if none found.
  39444. */
  39445. getLightByName(name: string): Nullable<Light>;
  39446. /**
  39447. * Gets a light node using its id
  39448. * @param id defines the light's id
  39449. * @return the light or null if none found.
  39450. */
  39451. getLightByID(id: string): Nullable<Light>;
  39452. /**
  39453. * Gets a light node using its scene-generated unique ID
  39454. * @param uniqueId defines the light's unique id
  39455. * @return the light or null if none found.
  39456. */
  39457. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  39458. /**
  39459. * Gets a particle system by id
  39460. * @param id defines the particle system id
  39461. * @return the corresponding system or null if none found
  39462. */
  39463. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  39464. /**
  39465. * Gets a geometry using its ID
  39466. * @param id defines the geometry's id
  39467. * @return the geometry or null if none found.
  39468. */
  39469. getGeometryByID(id: string): Nullable<Geometry>;
  39470. private _getGeometryByUniqueID;
  39471. /**
  39472. * Add a new geometry to this scene
  39473. * @param geometry defines the geometry to be added to the scene.
  39474. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  39475. * @return a boolean defining if the geometry was added or not
  39476. */
  39477. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  39478. /**
  39479. * Removes an existing geometry
  39480. * @param geometry defines the geometry to be removed from the scene
  39481. * @return a boolean defining if the geometry was removed or not
  39482. */
  39483. removeGeometry(geometry: Geometry): boolean;
  39484. /**
  39485. * Gets the list of geometries attached to the scene
  39486. * @returns an array of Geometry
  39487. */
  39488. getGeometries(): Geometry[];
  39489. /**
  39490. * Gets the first added mesh found of a given ID
  39491. * @param id defines the id to search for
  39492. * @return the mesh found or null if not found at all
  39493. */
  39494. getMeshByID(id: string): Nullable<AbstractMesh>;
  39495. /**
  39496. * Gets a list of meshes using their id
  39497. * @param id defines the id to search for
  39498. * @returns a list of meshes
  39499. */
  39500. getMeshesByID(id: string): Array<AbstractMesh>;
  39501. /**
  39502. * Gets the first added transform node found of a given ID
  39503. * @param id defines the id to search for
  39504. * @return the found transform node or null if not found at all.
  39505. */
  39506. getTransformNodeByID(id: string): Nullable<TransformNode>;
  39507. /**
  39508. * Gets a transform node with its auto-generated unique id
  39509. * @param uniqueId efines the unique id to search for
  39510. * @return the found transform node or null if not found at all.
  39511. */
  39512. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  39513. /**
  39514. * Gets a list of transform nodes using their id
  39515. * @param id defines the id to search for
  39516. * @returns a list of transform nodes
  39517. */
  39518. getTransformNodesByID(id: string): Array<TransformNode>;
  39519. /**
  39520. * Gets a mesh with its auto-generated unique id
  39521. * @param uniqueId defines the unique id to search for
  39522. * @return the found mesh or null if not found at all.
  39523. */
  39524. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  39525. /**
  39526. * Gets a the last added mesh using a given id
  39527. * @param id defines the id to search for
  39528. * @return the found mesh or null if not found at all.
  39529. */
  39530. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  39531. /**
  39532. * Gets a the last added node (Mesh, Camera, Light) using a given id
  39533. * @param id defines the id to search for
  39534. * @return the found node or null if not found at all
  39535. */
  39536. getLastEntryByID(id: string): Nullable<Node>;
  39537. /**
  39538. * Gets a node (Mesh, Camera, Light) using a given id
  39539. * @param id defines the id to search for
  39540. * @return the found node or null if not found at all
  39541. */
  39542. getNodeByID(id: string): Nullable<Node>;
  39543. /**
  39544. * Gets a node (Mesh, Camera, Light) using a given name
  39545. * @param name defines the name to search for
  39546. * @return the found node or null if not found at all.
  39547. */
  39548. getNodeByName(name: string): Nullable<Node>;
  39549. /**
  39550. * Gets a mesh using a given name
  39551. * @param name defines the name to search for
  39552. * @return the found mesh or null if not found at all.
  39553. */
  39554. getMeshByName(name: string): Nullable<AbstractMesh>;
  39555. /**
  39556. * Gets a transform node using a given name
  39557. * @param name defines the name to search for
  39558. * @return the found transform node or null if not found at all.
  39559. */
  39560. getTransformNodeByName(name: string): Nullable<TransformNode>;
  39561. /**
  39562. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  39563. * @param id defines the id to search for
  39564. * @return the found skeleton or null if not found at all.
  39565. */
  39566. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  39567. /**
  39568. * Gets a skeleton using a given auto generated unique id
  39569. * @param uniqueId defines the unique id to search for
  39570. * @return the found skeleton or null if not found at all.
  39571. */
  39572. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  39573. /**
  39574. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  39575. * @param id defines the id to search for
  39576. * @return the found skeleton or null if not found at all.
  39577. */
  39578. getSkeletonById(id: string): Nullable<Skeleton>;
  39579. /**
  39580. * Gets a skeleton using a given name
  39581. * @param name defines the name to search for
  39582. * @return the found skeleton or null if not found at all.
  39583. */
  39584. getSkeletonByName(name: string): Nullable<Skeleton>;
  39585. /**
  39586. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  39587. * @param id defines the id to search for
  39588. * @return the found morph target manager or null if not found at all.
  39589. */
  39590. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  39591. /**
  39592. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  39593. * @param id defines the id to search for
  39594. * @return the found morph target or null if not found at all.
  39595. */
  39596. getMorphTargetById(id: string): Nullable<MorphTarget>;
  39597. /**
  39598. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  39599. * @param name defines the name to search for
  39600. * @return the found morph target or null if not found at all.
  39601. */
  39602. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  39603. /**
  39604. * Gets a boolean indicating if the given mesh is active
  39605. * @param mesh defines the mesh to look for
  39606. * @returns true if the mesh is in the active list
  39607. */
  39608. isActiveMesh(mesh: AbstractMesh): boolean;
  39609. /**
  39610. * Return a unique id as a string which can serve as an identifier for the scene
  39611. */
  39612. get uid(): string;
  39613. /**
  39614. * Add an externaly attached data from its key.
  39615. * This method call will fail and return false, if such key already exists.
  39616. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  39617. * @param key the unique key that identifies the data
  39618. * @param data the data object to associate to the key for this Engine instance
  39619. * @return true if no such key were already present and the data was added successfully, false otherwise
  39620. */
  39621. addExternalData<T>(key: string, data: T): boolean;
  39622. /**
  39623. * Get an externaly attached data from its key
  39624. * @param key the unique key that identifies the data
  39625. * @return the associated data, if present (can be null), or undefined if not present
  39626. */
  39627. getExternalData<T>(key: string): Nullable<T>;
  39628. /**
  39629. * Get an externaly attached data from its key, create it using a factory if it's not already present
  39630. * @param key the unique key that identifies the data
  39631. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  39632. * @return the associated data, can be null if the factory returned null.
  39633. */
  39634. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  39635. /**
  39636. * Remove an externaly attached data from the Engine instance
  39637. * @param key the unique key that identifies the data
  39638. * @return true if the data was successfully removed, false if it doesn't exist
  39639. */
  39640. removeExternalData(key: string): boolean;
  39641. private _evaluateSubMesh;
  39642. /**
  39643. * Clear the processed materials smart array preventing retention point in material dispose.
  39644. */
  39645. freeProcessedMaterials(): void;
  39646. private _preventFreeActiveMeshesAndRenderingGroups;
  39647. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  39648. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  39649. * when disposing several meshes in a row or a hierarchy of meshes.
  39650. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  39651. */
  39652. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  39653. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  39654. /**
  39655. * Clear the active meshes smart array preventing retention point in mesh dispose.
  39656. */
  39657. freeActiveMeshes(): void;
  39658. /**
  39659. * Clear the info related to rendering groups preventing retention points during dispose.
  39660. */
  39661. freeRenderingGroups(): void;
  39662. /** @hidden */
  39663. _isInIntermediateRendering(): boolean;
  39664. /**
  39665. * Lambda returning the list of potentially active meshes.
  39666. */
  39667. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  39668. /**
  39669. * Lambda returning the list of potentially active sub meshes.
  39670. */
  39671. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  39672. /**
  39673. * Lambda returning the list of potentially intersecting sub meshes.
  39674. */
  39675. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  39676. /**
  39677. * Lambda returning the list of potentially colliding sub meshes.
  39678. */
  39679. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  39680. private _activeMeshesFrozen;
  39681. private _skipEvaluateActiveMeshesCompletely;
  39682. /**
  39683. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  39684. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  39685. * @returns the current scene
  39686. */
  39687. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  39688. /**
  39689. * Use this function to restart evaluating active meshes on every frame
  39690. * @returns the current scene
  39691. */
  39692. unfreezeActiveMeshes(): Scene;
  39693. private _evaluateActiveMeshes;
  39694. private _activeMesh;
  39695. /**
  39696. * Update the transform matrix to update from the current active camera
  39697. * @param force defines a boolean used to force the update even if cache is up to date
  39698. */
  39699. updateTransformMatrix(force?: boolean): void;
  39700. private _bindFrameBuffer;
  39701. /** @hidden */
  39702. _allowPostProcessClearColor: boolean;
  39703. /** @hidden */
  39704. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  39705. private _processSubCameras;
  39706. private _checkIntersections;
  39707. /** @hidden */
  39708. _advancePhysicsEngineStep(step: number): void;
  39709. /**
  39710. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  39711. */
  39712. getDeterministicFrameTime: () => number;
  39713. /** @hidden */
  39714. _animate(): void;
  39715. /** Execute all animations (for a frame) */
  39716. animate(): void;
  39717. /**
  39718. * Render the scene
  39719. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  39720. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  39721. */
  39722. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  39723. /**
  39724. * Freeze all materials
  39725. * A frozen material will not be updatable but should be faster to render
  39726. */
  39727. freezeMaterials(): void;
  39728. /**
  39729. * Unfreeze all materials
  39730. * A frozen material will not be updatable but should be faster to render
  39731. */
  39732. unfreezeMaterials(): void;
  39733. /**
  39734. * Releases all held ressources
  39735. */
  39736. dispose(): void;
  39737. /**
  39738. * Gets if the scene is already disposed
  39739. */
  39740. get isDisposed(): boolean;
  39741. /**
  39742. * Call this function to reduce memory footprint of the scene.
  39743. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  39744. */
  39745. clearCachedVertexData(): void;
  39746. /**
  39747. * This function will remove the local cached buffer data from texture.
  39748. * It will save memory but will prevent the texture from being rebuilt
  39749. */
  39750. cleanCachedTextureBuffer(): void;
  39751. /**
  39752. * Get the world extend vectors with an optional filter
  39753. *
  39754. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  39755. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  39756. */
  39757. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  39758. min: Vector3;
  39759. max: Vector3;
  39760. };
  39761. /**
  39762. * Creates a ray that can be used to pick in the scene
  39763. * @param x defines the x coordinate of the origin (on-screen)
  39764. * @param y defines the y coordinate of the origin (on-screen)
  39765. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  39766. * @param camera defines the camera to use for the picking
  39767. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  39768. * @returns a Ray
  39769. */
  39770. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  39771. /**
  39772. * Creates a ray that can be used to pick in the scene
  39773. * @param x defines the x coordinate of the origin (on-screen)
  39774. * @param y defines the y coordinate of the origin (on-screen)
  39775. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  39776. * @param result defines the ray where to store the picking ray
  39777. * @param camera defines the camera to use for the picking
  39778. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  39779. * @returns the current scene
  39780. */
  39781. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  39782. /**
  39783. * Creates a ray that can be used to pick in the scene
  39784. * @param x defines the x coordinate of the origin (on-screen)
  39785. * @param y defines the y coordinate of the origin (on-screen)
  39786. * @param camera defines the camera to use for the picking
  39787. * @returns a Ray
  39788. */
  39789. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  39790. /**
  39791. * Creates a ray that can be used to pick in the scene
  39792. * @param x defines the x coordinate of the origin (on-screen)
  39793. * @param y defines the y coordinate of the origin (on-screen)
  39794. * @param result defines the ray where to store the picking ray
  39795. * @param camera defines the camera to use for the picking
  39796. * @returns the current scene
  39797. */
  39798. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  39799. /** Launch a ray to try to pick a mesh in the scene
  39800. * @param x position on screen
  39801. * @param y position on screen
  39802. * @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
  39803. * @param fastCheck defines if the first intersection will be used (and not the closest)
  39804. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  39805. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  39806. * @returns a PickingInfo
  39807. */
  39808. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  39809. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  39810. * @param x position on screen
  39811. * @param y position on screen
  39812. * @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
  39813. * @param fastCheck defines if the first intersection will be used (and not the closest)
  39814. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  39815. * @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)
  39816. */
  39817. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  39818. /** Use the given ray to pick a mesh in the scene
  39819. * @param ray The ray to use to pick meshes
  39820. * @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
  39821. * @param fastCheck defines if the first intersection will be used (and not the closest)
  39822. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  39823. * @returns a PickingInfo
  39824. */
  39825. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  39826. /**
  39827. * Launch a ray to try to pick a mesh in the scene
  39828. * @param x X position on screen
  39829. * @param y Y position on screen
  39830. * @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
  39831. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  39832. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  39833. * @returns an array of PickingInfo
  39834. */
  39835. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  39836. /**
  39837. * Launch a ray to try to pick a mesh in the scene
  39838. * @param ray Ray to use
  39839. * @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
  39840. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  39841. * @returns an array of PickingInfo
  39842. */
  39843. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  39844. /**
  39845. * Force the value of meshUnderPointer
  39846. * @param mesh defines the mesh to use
  39847. */
  39848. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  39849. /**
  39850. * Gets the mesh under the pointer
  39851. * @returns a Mesh or null if no mesh is under the pointer
  39852. */
  39853. getPointerOverMesh(): Nullable<AbstractMesh>;
  39854. /** @hidden */
  39855. _rebuildGeometries(): void;
  39856. /** @hidden */
  39857. _rebuildTextures(): void;
  39858. private _getByTags;
  39859. /**
  39860. * Get a list of meshes by tags
  39861. * @param tagsQuery defines the tags query to use
  39862. * @param forEach defines a predicate used to filter results
  39863. * @returns an array of Mesh
  39864. */
  39865. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  39866. /**
  39867. * Get a list of cameras by tags
  39868. * @param tagsQuery defines the tags query to use
  39869. * @param forEach defines a predicate used to filter results
  39870. * @returns an array of Camera
  39871. */
  39872. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  39873. /**
  39874. * Get a list of lights by tags
  39875. * @param tagsQuery defines the tags query to use
  39876. * @param forEach defines a predicate used to filter results
  39877. * @returns an array of Light
  39878. */
  39879. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  39880. /**
  39881. * Get a list of materials by tags
  39882. * @param tagsQuery defines the tags query to use
  39883. * @param forEach defines a predicate used to filter results
  39884. * @returns an array of Material
  39885. */
  39886. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  39887. /**
  39888. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  39889. * This allowed control for front to back rendering or reversly depending of the special needs.
  39890. *
  39891. * @param renderingGroupId The rendering group id corresponding to its index
  39892. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  39893. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  39894. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  39895. */
  39896. 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;
  39897. /**
  39898. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  39899. *
  39900. * @param renderingGroupId The rendering group id corresponding to its index
  39901. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  39902. * @param depth Automatically clears depth between groups if true and autoClear is true.
  39903. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  39904. */
  39905. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  39906. /**
  39907. * Gets the current auto clear configuration for one rendering group of the rendering
  39908. * manager.
  39909. * @param index the rendering group index to get the information for
  39910. * @returns The auto clear setup for the requested rendering group
  39911. */
  39912. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  39913. private _blockMaterialDirtyMechanism;
  39914. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  39915. get blockMaterialDirtyMechanism(): boolean;
  39916. set blockMaterialDirtyMechanism(value: boolean);
  39917. /**
  39918. * Will flag all materials as dirty to trigger new shader compilation
  39919. * @param flag defines the flag used to specify which material part must be marked as dirty
  39920. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  39921. */
  39922. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  39923. /** @hidden */
  39924. _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;
  39925. /** @hidden */
  39926. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  39927. /** @hidden */
  39928. _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;
  39929. /** @hidden */
  39930. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  39931. /** @hidden */
  39932. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  39933. /** @hidden */
  39934. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  39935. }
  39936. }
  39937. declare module BABYLON {
  39938. /**
  39939. * Set of assets to keep when moving a scene into an asset container.
  39940. */
  39941. export class KeepAssets extends AbstractScene {
  39942. }
  39943. /**
  39944. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  39945. */
  39946. export class InstantiatedEntries {
  39947. /**
  39948. * List of new root nodes (eg. nodes with no parent)
  39949. */
  39950. rootNodes: TransformNode[];
  39951. /**
  39952. * List of new skeletons
  39953. */
  39954. skeletons: Skeleton[];
  39955. /**
  39956. * List of new animation groups
  39957. */
  39958. animationGroups: AnimationGroup[];
  39959. }
  39960. /**
  39961. * Container with a set of assets that can be added or removed from a scene.
  39962. */
  39963. export class AssetContainer extends AbstractScene {
  39964. private _wasAddedToScene;
  39965. /**
  39966. * The scene the AssetContainer belongs to.
  39967. */
  39968. scene: Scene;
  39969. /**
  39970. * Instantiates an AssetContainer.
  39971. * @param scene The scene the AssetContainer belongs to.
  39972. */
  39973. constructor(scene: Scene);
  39974. /**
  39975. * Instantiate or clone all meshes and add the new ones to the scene.
  39976. * Skeletons and animation groups will all be cloned
  39977. * @param nameFunction defines an optional function used to get new names for clones
  39978. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  39979. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  39980. */
  39981. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  39982. /**
  39983. * Adds all the assets from the container to the scene.
  39984. */
  39985. addAllToScene(): void;
  39986. /**
  39987. * Removes all the assets in the container from the scene
  39988. */
  39989. removeAllFromScene(): void;
  39990. /**
  39991. * Disposes all the assets in the container
  39992. */
  39993. dispose(): void;
  39994. private _moveAssets;
  39995. /**
  39996. * Removes all the assets contained in the scene and adds them to the container.
  39997. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  39998. */
  39999. moveAllFromScene(keepAssets?: KeepAssets): void;
  40000. /**
  40001. * 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.
  40002. * @returns the root mesh
  40003. */
  40004. createRootMesh(): Mesh;
  40005. /**
  40006. * Merge animations (direct and animation groups) from this asset container into a scene
  40007. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  40008. * @param animatables set of animatables to retarget to a node from the scene
  40009. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  40010. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  40011. */
  40012. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  40013. }
  40014. }
  40015. declare module BABYLON {
  40016. /**
  40017. * Defines how the parser contract is defined.
  40018. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  40019. */
  40020. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  40021. /**
  40022. * Defines how the individual parser contract is defined.
  40023. * These parser can parse an individual asset
  40024. */
  40025. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  40026. /**
  40027. * Base class of the scene acting as a container for the different elements composing a scene.
  40028. * This class is dynamically extended by the different components of the scene increasing
  40029. * flexibility and reducing coupling
  40030. */
  40031. export abstract class AbstractScene {
  40032. /**
  40033. * Stores the list of available parsers in the application.
  40034. */
  40035. private static _BabylonFileParsers;
  40036. /**
  40037. * Stores the list of available individual parsers in the application.
  40038. */
  40039. private static _IndividualBabylonFileParsers;
  40040. /**
  40041. * Adds a parser in the list of available ones
  40042. * @param name Defines the name of the parser
  40043. * @param parser Defines the parser to add
  40044. */
  40045. static AddParser(name: string, parser: BabylonFileParser): void;
  40046. /**
  40047. * Gets a general parser from the list of avaialble ones
  40048. * @param name Defines the name of the parser
  40049. * @returns the requested parser or null
  40050. */
  40051. static GetParser(name: string): Nullable<BabylonFileParser>;
  40052. /**
  40053. * Adds n individual parser in the list of available ones
  40054. * @param name Defines the name of the parser
  40055. * @param parser Defines the parser to add
  40056. */
  40057. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  40058. /**
  40059. * Gets an individual parser from the list of avaialble ones
  40060. * @param name Defines the name of the parser
  40061. * @returns the requested parser or null
  40062. */
  40063. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  40064. /**
  40065. * Parser json data and populate both a scene and its associated container object
  40066. * @param jsonData Defines the data to parse
  40067. * @param scene Defines the scene to parse the data for
  40068. * @param container Defines the container attached to the parsing sequence
  40069. * @param rootUrl Defines the root url of the data
  40070. */
  40071. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  40072. /**
  40073. * Gets the list of root nodes (ie. nodes with no parent)
  40074. */
  40075. rootNodes: Node[];
  40076. /** All of the cameras added to this scene
  40077. * @see http://doc.babylonjs.com/babylon101/cameras
  40078. */
  40079. cameras: Camera[];
  40080. /**
  40081. * All of the lights added to this scene
  40082. * @see http://doc.babylonjs.com/babylon101/lights
  40083. */
  40084. lights: Light[];
  40085. /**
  40086. * All of the (abstract) meshes added to this scene
  40087. */
  40088. meshes: AbstractMesh[];
  40089. /**
  40090. * The list of skeletons added to the scene
  40091. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  40092. */
  40093. skeletons: Skeleton[];
  40094. /**
  40095. * All of the particle systems added to this scene
  40096. * @see http://doc.babylonjs.com/babylon101/particles
  40097. */
  40098. particleSystems: IParticleSystem[];
  40099. /**
  40100. * Gets a list of Animations associated with the scene
  40101. */
  40102. animations: Animation[];
  40103. /**
  40104. * All of the animation groups added to this scene
  40105. * @see http://doc.babylonjs.com/how_to/group
  40106. */
  40107. animationGroups: AnimationGroup[];
  40108. /**
  40109. * All of the multi-materials added to this scene
  40110. * @see http://doc.babylonjs.com/how_to/multi_materials
  40111. */
  40112. multiMaterials: MultiMaterial[];
  40113. /**
  40114. * All of the materials added to this scene
  40115. * In the context of a Scene, it is not supposed to be modified manually.
  40116. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  40117. * Note also that the order of the Material within the array is not significant and might change.
  40118. * @see http://doc.babylonjs.com/babylon101/materials
  40119. */
  40120. materials: Material[];
  40121. /**
  40122. * The list of morph target managers added to the scene
  40123. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  40124. */
  40125. morphTargetManagers: MorphTargetManager[];
  40126. /**
  40127. * The list of geometries used in the scene.
  40128. */
  40129. geometries: Geometry[];
  40130. /**
  40131. * All of the tranform nodes added to this scene
  40132. * In the context of a Scene, it is not supposed to be modified manually.
  40133. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  40134. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  40135. * @see http://doc.babylonjs.com/how_to/transformnode
  40136. */
  40137. transformNodes: TransformNode[];
  40138. /**
  40139. * ActionManagers available on the scene.
  40140. */
  40141. actionManagers: AbstractActionManager[];
  40142. /**
  40143. * Textures to keep.
  40144. */
  40145. textures: BaseTexture[];
  40146. /**
  40147. * Environment texture for the scene
  40148. */
  40149. environmentTexture: Nullable<BaseTexture>;
  40150. /**
  40151. * @returns all meshes, lights, cameras, transformNodes and bones
  40152. */
  40153. getNodes(): Array<Node>;
  40154. }
  40155. }
  40156. declare module BABYLON {
  40157. /**
  40158. * Interface used to define options for Sound class
  40159. */
  40160. export interface ISoundOptions {
  40161. /**
  40162. * Does the sound autoplay once loaded.
  40163. */
  40164. autoplay?: boolean;
  40165. /**
  40166. * Does the sound loop after it finishes playing once.
  40167. */
  40168. loop?: boolean;
  40169. /**
  40170. * Sound's volume
  40171. */
  40172. volume?: number;
  40173. /**
  40174. * Is it a spatial sound?
  40175. */
  40176. spatialSound?: boolean;
  40177. /**
  40178. * Maximum distance to hear that sound
  40179. */
  40180. maxDistance?: number;
  40181. /**
  40182. * Uses user defined attenuation function
  40183. */
  40184. useCustomAttenuation?: boolean;
  40185. /**
  40186. * Define the roll off factor of spatial sounds.
  40187. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40188. */
  40189. rolloffFactor?: number;
  40190. /**
  40191. * Define the reference distance the sound should be heard perfectly.
  40192. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40193. */
  40194. refDistance?: number;
  40195. /**
  40196. * Define the distance attenuation model the sound will follow.
  40197. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40198. */
  40199. distanceModel?: string;
  40200. /**
  40201. * Defines the playback speed (1 by default)
  40202. */
  40203. playbackRate?: number;
  40204. /**
  40205. * Defines if the sound is from a streaming source
  40206. */
  40207. streaming?: boolean;
  40208. /**
  40209. * Defines an optional length (in seconds) inside the sound file
  40210. */
  40211. length?: number;
  40212. /**
  40213. * Defines an optional offset (in seconds) inside the sound file
  40214. */
  40215. offset?: number;
  40216. /**
  40217. * If true, URLs will not be required to state the audio file codec to use.
  40218. */
  40219. skipCodecCheck?: boolean;
  40220. }
  40221. /**
  40222. * Defines a sound that can be played in the application.
  40223. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  40224. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40225. */
  40226. export class Sound {
  40227. /**
  40228. * The name of the sound in the scene.
  40229. */
  40230. name: string;
  40231. /**
  40232. * Does the sound autoplay once loaded.
  40233. */
  40234. autoplay: boolean;
  40235. /**
  40236. * Does the sound loop after it finishes playing once.
  40237. */
  40238. loop: boolean;
  40239. /**
  40240. * Does the sound use a custom attenuation curve to simulate the falloff
  40241. * happening when the source gets further away from the camera.
  40242. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40243. */
  40244. useCustomAttenuation: boolean;
  40245. /**
  40246. * The sound track id this sound belongs to.
  40247. */
  40248. soundTrackId: number;
  40249. /**
  40250. * Is this sound currently played.
  40251. */
  40252. isPlaying: boolean;
  40253. /**
  40254. * Is this sound currently paused.
  40255. */
  40256. isPaused: boolean;
  40257. /**
  40258. * Does this sound enables spatial sound.
  40259. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40260. */
  40261. spatialSound: boolean;
  40262. /**
  40263. * Define the reference distance the sound should be heard perfectly.
  40264. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40265. */
  40266. refDistance: number;
  40267. /**
  40268. * Define the roll off factor of spatial sounds.
  40269. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40270. */
  40271. rolloffFactor: number;
  40272. /**
  40273. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  40274. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40275. */
  40276. maxDistance: number;
  40277. /**
  40278. * Define the distance attenuation model the sound will follow.
  40279. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40280. */
  40281. distanceModel: string;
  40282. /**
  40283. * @hidden
  40284. * Back Compat
  40285. **/
  40286. onended: () => any;
  40287. /**
  40288. * Gets or sets an object used to store user defined information for the sound.
  40289. */
  40290. metadata: any;
  40291. /**
  40292. * Observable event when the current playing sound finishes.
  40293. */
  40294. onEndedObservable: Observable<Sound>;
  40295. private _panningModel;
  40296. private _playbackRate;
  40297. private _streaming;
  40298. private _startTime;
  40299. private _startOffset;
  40300. private _position;
  40301. /** @hidden */
  40302. _positionInEmitterSpace: boolean;
  40303. private _localDirection;
  40304. private _volume;
  40305. private _isReadyToPlay;
  40306. private _isDirectional;
  40307. private _readyToPlayCallback;
  40308. private _audioBuffer;
  40309. private _soundSource;
  40310. private _streamingSource;
  40311. private _soundPanner;
  40312. private _soundGain;
  40313. private _inputAudioNode;
  40314. private _outputAudioNode;
  40315. private _coneInnerAngle;
  40316. private _coneOuterAngle;
  40317. private _coneOuterGain;
  40318. private _scene;
  40319. private _connectedTransformNode;
  40320. private _customAttenuationFunction;
  40321. private _registerFunc;
  40322. private _isOutputConnected;
  40323. private _htmlAudioElement;
  40324. private _urlType;
  40325. private _length?;
  40326. private _offset?;
  40327. /** @hidden */
  40328. static _SceneComponentInitialization: (scene: Scene) => void;
  40329. /**
  40330. * Create a sound and attach it to a scene
  40331. * @param name Name of your sound
  40332. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  40333. * @param scene defines the scene the sound belongs to
  40334. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  40335. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  40336. */
  40337. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  40338. /**
  40339. * Release the sound and its associated resources
  40340. */
  40341. dispose(): void;
  40342. /**
  40343. * Gets if the sounds is ready to be played or not.
  40344. * @returns true if ready, otherwise false
  40345. */
  40346. isReady(): boolean;
  40347. private _soundLoaded;
  40348. /**
  40349. * Sets the data of the sound from an audiobuffer
  40350. * @param audioBuffer The audioBuffer containing the data
  40351. */
  40352. setAudioBuffer(audioBuffer: AudioBuffer): void;
  40353. /**
  40354. * Updates the current sounds options such as maxdistance, loop...
  40355. * @param options A JSON object containing values named as the object properties
  40356. */
  40357. updateOptions(options: ISoundOptions): void;
  40358. private _createSpatialParameters;
  40359. private _updateSpatialParameters;
  40360. /**
  40361. * Switch the panning model to HRTF:
  40362. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  40363. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40364. */
  40365. switchPanningModelToHRTF(): void;
  40366. /**
  40367. * Switch the panning model to Equal Power:
  40368. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  40369. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40370. */
  40371. switchPanningModelToEqualPower(): void;
  40372. private _switchPanningModel;
  40373. /**
  40374. * Connect this sound to a sound track audio node like gain...
  40375. * @param soundTrackAudioNode the sound track audio node to connect to
  40376. */
  40377. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  40378. /**
  40379. * Transform this sound into a directional source
  40380. * @param coneInnerAngle Size of the inner cone in degree
  40381. * @param coneOuterAngle Size of the outer cone in degree
  40382. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  40383. */
  40384. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  40385. /**
  40386. * Gets or sets the inner angle for the directional cone.
  40387. */
  40388. get directionalConeInnerAngle(): number;
  40389. /**
  40390. * Gets or sets the inner angle for the directional cone.
  40391. */
  40392. set directionalConeInnerAngle(value: number);
  40393. /**
  40394. * Gets or sets the outer angle for the directional cone.
  40395. */
  40396. get directionalConeOuterAngle(): number;
  40397. /**
  40398. * Gets or sets the outer angle for the directional cone.
  40399. */
  40400. set directionalConeOuterAngle(value: number);
  40401. /**
  40402. * Sets the position of the emitter if spatial sound is enabled
  40403. * @param newPosition Defines the new posisiton
  40404. */
  40405. setPosition(newPosition: Vector3): void;
  40406. /**
  40407. * Sets the local direction of the emitter if spatial sound is enabled
  40408. * @param newLocalDirection Defines the new local direction
  40409. */
  40410. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  40411. private _updateDirection;
  40412. /** @hidden */
  40413. updateDistanceFromListener(): void;
  40414. /**
  40415. * Sets a new custom attenuation function for the sound.
  40416. * @param callback Defines the function used for the attenuation
  40417. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40418. */
  40419. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  40420. /**
  40421. * Play the sound
  40422. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  40423. * @param offset (optional) Start the sound at a specific time in seconds
  40424. * @param length (optional) Sound duration (in seconds)
  40425. */
  40426. play(time?: number, offset?: number, length?: number): void;
  40427. private _onended;
  40428. /**
  40429. * Stop the sound
  40430. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  40431. */
  40432. stop(time?: number): void;
  40433. /**
  40434. * Put the sound in pause
  40435. */
  40436. pause(): void;
  40437. /**
  40438. * Sets a dedicated volume for this sounds
  40439. * @param newVolume Define the new volume of the sound
  40440. * @param time Define time for gradual change to new volume
  40441. */
  40442. setVolume(newVolume: number, time?: number): void;
  40443. /**
  40444. * Set the sound play back rate
  40445. * @param newPlaybackRate Define the playback rate the sound should be played at
  40446. */
  40447. setPlaybackRate(newPlaybackRate: number): void;
  40448. /**
  40449. * Gets the volume of the sound.
  40450. * @returns the volume of the sound
  40451. */
  40452. getVolume(): number;
  40453. /**
  40454. * Attach the sound to a dedicated mesh
  40455. * @param transformNode The transform node to connect the sound with
  40456. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40457. */
  40458. attachToMesh(transformNode: TransformNode): void;
  40459. /**
  40460. * Detach the sound from the previously attached mesh
  40461. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40462. */
  40463. detachFromMesh(): void;
  40464. private _onRegisterAfterWorldMatrixUpdate;
  40465. /**
  40466. * Clone the current sound in the scene.
  40467. * @returns the new sound clone
  40468. */
  40469. clone(): Nullable<Sound>;
  40470. /**
  40471. * Gets the current underlying audio buffer containing the data
  40472. * @returns the audio buffer
  40473. */
  40474. getAudioBuffer(): Nullable<AudioBuffer>;
  40475. /**
  40476. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  40477. * @returns the source node
  40478. */
  40479. getSoundSource(): Nullable<AudioBufferSourceNode>;
  40480. /**
  40481. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  40482. * @returns the gain node
  40483. */
  40484. getSoundGain(): Nullable<GainNode>;
  40485. /**
  40486. * Serializes the Sound in a JSON representation
  40487. * @returns the JSON representation of the sound
  40488. */
  40489. serialize(): any;
  40490. /**
  40491. * Parse a JSON representation of a sound to innstantiate in a given scene
  40492. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  40493. * @param scene Define the scene the new parsed sound should be created in
  40494. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  40495. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  40496. * @returns the newly parsed sound
  40497. */
  40498. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  40499. }
  40500. }
  40501. declare module BABYLON {
  40502. /**
  40503. * This defines an action helpful to play a defined sound on a triggered action.
  40504. */
  40505. export class PlaySoundAction extends Action {
  40506. private _sound;
  40507. /**
  40508. * Instantiate the action
  40509. * @param triggerOptions defines the trigger options
  40510. * @param sound defines the sound to play
  40511. * @param condition defines the trigger related conditions
  40512. */
  40513. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40514. /** @hidden */
  40515. _prepare(): void;
  40516. /**
  40517. * Execute the action and play the sound.
  40518. */
  40519. execute(): void;
  40520. /**
  40521. * Serializes the actions and its related information.
  40522. * @param parent defines the object to serialize in
  40523. * @returns the serialized object
  40524. */
  40525. serialize(parent: any): any;
  40526. }
  40527. /**
  40528. * This defines an action helpful to stop a defined sound on a triggered action.
  40529. */
  40530. export class StopSoundAction extends Action {
  40531. private _sound;
  40532. /**
  40533. * Instantiate the action
  40534. * @param triggerOptions defines the trigger options
  40535. * @param sound defines the sound to stop
  40536. * @param condition defines the trigger related conditions
  40537. */
  40538. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40539. /** @hidden */
  40540. _prepare(): void;
  40541. /**
  40542. * Execute the action and stop the sound.
  40543. */
  40544. execute(): void;
  40545. /**
  40546. * Serializes the actions and its related information.
  40547. * @param parent defines the object to serialize in
  40548. * @returns the serialized object
  40549. */
  40550. serialize(parent: any): any;
  40551. }
  40552. }
  40553. declare module BABYLON {
  40554. /**
  40555. * This defines an action responsible to change the value of a property
  40556. * by interpolating between its current value and the newly set one once triggered.
  40557. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  40558. */
  40559. export class InterpolateValueAction extends Action {
  40560. /**
  40561. * Defines the path of the property where the value should be interpolated
  40562. */
  40563. propertyPath: string;
  40564. /**
  40565. * Defines the target value at the end of the interpolation.
  40566. */
  40567. value: any;
  40568. /**
  40569. * Defines the time it will take for the property to interpolate to the value.
  40570. */
  40571. duration: number;
  40572. /**
  40573. * Defines if the other scene animations should be stopped when the action has been triggered
  40574. */
  40575. stopOtherAnimations?: boolean;
  40576. /**
  40577. * Defines a callback raised once the interpolation animation has been done.
  40578. */
  40579. onInterpolationDone?: () => void;
  40580. /**
  40581. * Observable triggered once the interpolation animation has been done.
  40582. */
  40583. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  40584. private _target;
  40585. private _effectiveTarget;
  40586. private _property;
  40587. /**
  40588. * Instantiate the action
  40589. * @param triggerOptions defines the trigger options
  40590. * @param target defines the object containing the value to interpolate
  40591. * @param propertyPath defines the path to the property in the target object
  40592. * @param value defines the target value at the end of the interpolation
  40593. * @param duration deines the time it will take for the property to interpolate to the value.
  40594. * @param condition defines the trigger related conditions
  40595. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  40596. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  40597. */
  40598. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  40599. /** @hidden */
  40600. _prepare(): void;
  40601. /**
  40602. * Execute the action starts the value interpolation.
  40603. */
  40604. execute(): void;
  40605. /**
  40606. * Serializes the actions and its related information.
  40607. * @param parent defines the object to serialize in
  40608. * @returns the serialized object
  40609. */
  40610. serialize(parent: any): any;
  40611. }
  40612. }
  40613. declare module BABYLON {
  40614. /**
  40615. * Options allowed during the creation of a sound track.
  40616. */
  40617. export interface ISoundTrackOptions {
  40618. /**
  40619. * The volume the sound track should take during creation
  40620. */
  40621. volume?: number;
  40622. /**
  40623. * Define if the sound track is the main sound track of the scene
  40624. */
  40625. mainTrack?: boolean;
  40626. }
  40627. /**
  40628. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  40629. * It will be also used in a future release to apply effects on a specific track.
  40630. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  40631. */
  40632. export class SoundTrack {
  40633. /**
  40634. * The unique identifier of the sound track in the scene.
  40635. */
  40636. id: number;
  40637. /**
  40638. * The list of sounds included in the sound track.
  40639. */
  40640. soundCollection: Array<Sound>;
  40641. private _outputAudioNode;
  40642. private _scene;
  40643. private _connectedAnalyser;
  40644. private _options;
  40645. private _isInitialized;
  40646. /**
  40647. * Creates a new sound track.
  40648. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  40649. * @param scene Define the scene the sound track belongs to
  40650. * @param options
  40651. */
  40652. constructor(scene: Scene, options?: ISoundTrackOptions);
  40653. private _initializeSoundTrackAudioGraph;
  40654. /**
  40655. * Release the sound track and its associated resources
  40656. */
  40657. dispose(): void;
  40658. /**
  40659. * Adds a sound to this sound track
  40660. * @param sound define the cound to add
  40661. * @ignoreNaming
  40662. */
  40663. AddSound(sound: Sound): void;
  40664. /**
  40665. * Removes a sound to this sound track
  40666. * @param sound define the cound to remove
  40667. * @ignoreNaming
  40668. */
  40669. RemoveSound(sound: Sound): void;
  40670. /**
  40671. * Set a global volume for the full sound track.
  40672. * @param newVolume Define the new volume of the sound track
  40673. */
  40674. setVolume(newVolume: number): void;
  40675. /**
  40676. * Switch the panning model to HRTF:
  40677. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  40678. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40679. */
  40680. switchPanningModelToHRTF(): void;
  40681. /**
  40682. * Switch the panning model to Equal Power:
  40683. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  40684. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40685. */
  40686. switchPanningModelToEqualPower(): void;
  40687. /**
  40688. * Connect the sound track to an audio analyser allowing some amazing
  40689. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  40690. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  40691. * @param analyser The analyser to connect to the engine
  40692. */
  40693. connectToAnalyser(analyser: Analyser): void;
  40694. }
  40695. }
  40696. declare module BABYLON {
  40697. interface AbstractScene {
  40698. /**
  40699. * The list of sounds used in the scene.
  40700. */
  40701. sounds: Nullable<Array<Sound>>;
  40702. }
  40703. interface Scene {
  40704. /**
  40705. * @hidden
  40706. * Backing field
  40707. */
  40708. _mainSoundTrack: SoundTrack;
  40709. /**
  40710. * The main sound track played by the scene.
  40711. * It cotains your primary collection of sounds.
  40712. */
  40713. mainSoundTrack: SoundTrack;
  40714. /**
  40715. * The list of sound tracks added to the scene
  40716. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40717. */
  40718. soundTracks: Nullable<Array<SoundTrack>>;
  40719. /**
  40720. * Gets a sound using a given name
  40721. * @param name defines the name to search for
  40722. * @return the found sound or null if not found at all.
  40723. */
  40724. getSoundByName(name: string): Nullable<Sound>;
  40725. /**
  40726. * Gets or sets if audio support is enabled
  40727. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40728. */
  40729. audioEnabled: boolean;
  40730. /**
  40731. * Gets or sets if audio will be output to headphones
  40732. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40733. */
  40734. headphone: boolean;
  40735. /**
  40736. * Gets or sets custom audio listener position provider
  40737. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40738. */
  40739. audioListenerPositionProvider: Nullable<() => Vector3>;
  40740. /**
  40741. * Gets or sets a refresh rate when using 3D audio positioning
  40742. */
  40743. audioPositioningRefreshRate: number;
  40744. }
  40745. /**
  40746. * Defines the sound scene component responsible to manage any sounds
  40747. * in a given scene.
  40748. */
  40749. export class AudioSceneComponent implements ISceneSerializableComponent {
  40750. /**
  40751. * The component name helpfull to identify the component in the list of scene components.
  40752. */
  40753. readonly name: string;
  40754. /**
  40755. * The scene the component belongs to.
  40756. */
  40757. scene: Scene;
  40758. private _audioEnabled;
  40759. /**
  40760. * Gets whether audio is enabled or not.
  40761. * Please use related enable/disable method to switch state.
  40762. */
  40763. get audioEnabled(): boolean;
  40764. private _headphone;
  40765. /**
  40766. * Gets whether audio is outputing to headphone or not.
  40767. * Please use the according Switch methods to change output.
  40768. */
  40769. get headphone(): boolean;
  40770. /**
  40771. * Gets or sets a refresh rate when using 3D audio positioning
  40772. */
  40773. audioPositioningRefreshRate: number;
  40774. private _audioListenerPositionProvider;
  40775. /**
  40776. * Gets the current audio listener position provider
  40777. */
  40778. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  40779. /**
  40780. * Sets a custom listener position for all sounds in the scene
  40781. * By default, this is the position of the first active camera
  40782. */
  40783. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  40784. /**
  40785. * Creates a new instance of the component for the given scene
  40786. * @param scene Defines the scene to register the component in
  40787. */
  40788. constructor(scene: Scene);
  40789. /**
  40790. * Registers the component in a given scene
  40791. */
  40792. register(): void;
  40793. /**
  40794. * Rebuilds the elements related to this component in case of
  40795. * context lost for instance.
  40796. */
  40797. rebuild(): void;
  40798. /**
  40799. * Serializes the component data to the specified json object
  40800. * @param serializationObject The object to serialize to
  40801. */
  40802. serialize(serializationObject: any): void;
  40803. /**
  40804. * Adds all the elements from the container to the scene
  40805. * @param container the container holding the elements
  40806. */
  40807. addFromContainer(container: AbstractScene): void;
  40808. /**
  40809. * Removes all the elements in the container from the scene
  40810. * @param container contains the elements to remove
  40811. * @param dispose if the removed element should be disposed (default: false)
  40812. */
  40813. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  40814. /**
  40815. * Disposes the component and the associated ressources.
  40816. */
  40817. dispose(): void;
  40818. /**
  40819. * Disables audio in the associated scene.
  40820. */
  40821. disableAudio(): void;
  40822. /**
  40823. * Enables audio in the associated scene.
  40824. */
  40825. enableAudio(): void;
  40826. /**
  40827. * Switch audio to headphone output.
  40828. */
  40829. switchAudioModeForHeadphones(): void;
  40830. /**
  40831. * Switch audio to normal speakers.
  40832. */
  40833. switchAudioModeForNormalSpeakers(): void;
  40834. private _cachedCameraDirection;
  40835. private _cachedCameraPosition;
  40836. private _lastCheck;
  40837. private _afterRender;
  40838. }
  40839. }
  40840. declare module BABYLON {
  40841. /**
  40842. * Wraps one or more Sound objects and selects one with random weight for playback.
  40843. */
  40844. export class WeightedSound {
  40845. /** When true a Sound will be selected and played when the current playing Sound completes. */
  40846. loop: boolean;
  40847. private _coneInnerAngle;
  40848. private _coneOuterAngle;
  40849. private _volume;
  40850. /** A Sound is currently playing. */
  40851. isPlaying: boolean;
  40852. /** A Sound is currently paused. */
  40853. isPaused: boolean;
  40854. private _sounds;
  40855. private _weights;
  40856. private _currentIndex?;
  40857. /**
  40858. * Creates a new WeightedSound from the list of sounds given.
  40859. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  40860. * @param sounds Array of Sounds that will be selected from.
  40861. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  40862. */
  40863. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  40864. /**
  40865. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  40866. */
  40867. get directionalConeInnerAngle(): number;
  40868. /**
  40869. * The size of cone in degress for a directional sound in which there will be no attenuation.
  40870. */
  40871. set directionalConeInnerAngle(value: number);
  40872. /**
  40873. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  40874. * Listener angles between innerAngle and outerAngle will falloff linearly.
  40875. */
  40876. get directionalConeOuterAngle(): number;
  40877. /**
  40878. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  40879. * Listener angles between innerAngle and outerAngle will falloff linearly.
  40880. */
  40881. set directionalConeOuterAngle(value: number);
  40882. /**
  40883. * Playback volume.
  40884. */
  40885. get volume(): number;
  40886. /**
  40887. * Playback volume.
  40888. */
  40889. set volume(value: number);
  40890. private _onended;
  40891. /**
  40892. * Suspend playback
  40893. */
  40894. pause(): void;
  40895. /**
  40896. * Stop playback
  40897. */
  40898. stop(): void;
  40899. /**
  40900. * Start playback.
  40901. * @param startOffset Position the clip head at a specific time in seconds.
  40902. */
  40903. play(startOffset?: number): void;
  40904. }
  40905. }
  40906. declare module BABYLON {
  40907. /**
  40908. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  40909. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40910. */
  40911. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  40912. /**
  40913. * Gets the name of the behavior.
  40914. */
  40915. get name(): string;
  40916. /**
  40917. * The easing function used by animations
  40918. */
  40919. static EasingFunction: BackEase;
  40920. /**
  40921. * The easing mode used by animations
  40922. */
  40923. static EasingMode: number;
  40924. /**
  40925. * The duration of the animation, in milliseconds
  40926. */
  40927. transitionDuration: number;
  40928. /**
  40929. * Length of the distance animated by the transition when lower radius is reached
  40930. */
  40931. lowerRadiusTransitionRange: number;
  40932. /**
  40933. * Length of the distance animated by the transition when upper radius is reached
  40934. */
  40935. upperRadiusTransitionRange: number;
  40936. private _autoTransitionRange;
  40937. /**
  40938. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40939. */
  40940. get autoTransitionRange(): boolean;
  40941. /**
  40942. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40943. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  40944. */
  40945. set autoTransitionRange(value: boolean);
  40946. private _attachedCamera;
  40947. private _onAfterCheckInputsObserver;
  40948. private _onMeshTargetChangedObserver;
  40949. /**
  40950. * Initializes the behavior.
  40951. */
  40952. init(): void;
  40953. /**
  40954. * Attaches the behavior to its arc rotate camera.
  40955. * @param camera Defines the camera to attach the behavior to
  40956. */
  40957. attach(camera: ArcRotateCamera): void;
  40958. /**
  40959. * Detaches the behavior from its current arc rotate camera.
  40960. */
  40961. detach(): void;
  40962. private _radiusIsAnimating;
  40963. private _radiusBounceTransition;
  40964. private _animatables;
  40965. private _cachedWheelPrecision;
  40966. /**
  40967. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  40968. * @param radiusLimit The limit to check against.
  40969. * @return Bool to indicate if at limit.
  40970. */
  40971. private _isRadiusAtLimit;
  40972. /**
  40973. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  40974. * @param radiusDelta The delta by which to animate to. Can be negative.
  40975. */
  40976. private _applyBoundRadiusAnimation;
  40977. /**
  40978. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  40979. */
  40980. protected _clearAnimationLocks(): void;
  40981. /**
  40982. * Stops and removes all animations that have been applied to the camera
  40983. */
  40984. stopAllAnimations(): void;
  40985. }
  40986. }
  40987. declare module BABYLON {
  40988. /**
  40989. * 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.
  40990. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40991. */
  40992. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  40993. /**
  40994. * Gets the name of the behavior.
  40995. */
  40996. get name(): string;
  40997. private _mode;
  40998. private _radiusScale;
  40999. private _positionScale;
  41000. private _defaultElevation;
  41001. private _elevationReturnTime;
  41002. private _elevationReturnWaitTime;
  41003. private _zoomStopsAnimation;
  41004. private _framingTime;
  41005. /**
  41006. * The easing function used by animations
  41007. */
  41008. static EasingFunction: ExponentialEase;
  41009. /**
  41010. * The easing mode used by animations
  41011. */
  41012. static EasingMode: number;
  41013. /**
  41014. * Sets the current mode used by the behavior
  41015. */
  41016. set mode(mode: number);
  41017. /**
  41018. * Gets current mode used by the behavior.
  41019. */
  41020. get mode(): number;
  41021. /**
  41022. * Sets the scale applied to the radius (1 by default)
  41023. */
  41024. set radiusScale(radius: number);
  41025. /**
  41026. * Gets the scale applied to the radius
  41027. */
  41028. get radiusScale(): number;
  41029. /**
  41030. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41031. */
  41032. set positionScale(scale: number);
  41033. /**
  41034. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41035. */
  41036. get positionScale(): number;
  41037. /**
  41038. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  41039. * behaviour is triggered, in radians.
  41040. */
  41041. set defaultElevation(elevation: number);
  41042. /**
  41043. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  41044. * behaviour is triggered, in radians.
  41045. */
  41046. get defaultElevation(): number;
  41047. /**
  41048. * Sets the time (in milliseconds) taken to return to the default beta position.
  41049. * Negative value indicates camera should not return to default.
  41050. */
  41051. set elevationReturnTime(speed: number);
  41052. /**
  41053. * Gets the time (in milliseconds) taken to return to the default beta position.
  41054. * Negative value indicates camera should not return to default.
  41055. */
  41056. get elevationReturnTime(): number;
  41057. /**
  41058. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41059. */
  41060. set elevationReturnWaitTime(time: number);
  41061. /**
  41062. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41063. */
  41064. get elevationReturnWaitTime(): number;
  41065. /**
  41066. * Sets the flag that indicates if user zooming should stop animation.
  41067. */
  41068. set zoomStopsAnimation(flag: boolean);
  41069. /**
  41070. * Gets the flag that indicates if user zooming should stop animation.
  41071. */
  41072. get zoomStopsAnimation(): boolean;
  41073. /**
  41074. * Sets the transition time when framing the mesh, in milliseconds
  41075. */
  41076. set framingTime(time: number);
  41077. /**
  41078. * Gets the transition time when framing the mesh, in milliseconds
  41079. */
  41080. get framingTime(): number;
  41081. /**
  41082. * Define if the behavior should automatically change the configured
  41083. * camera limits and sensibilities.
  41084. */
  41085. autoCorrectCameraLimitsAndSensibility: boolean;
  41086. private _onPrePointerObservableObserver;
  41087. private _onAfterCheckInputsObserver;
  41088. private _onMeshTargetChangedObserver;
  41089. private _attachedCamera;
  41090. private _isPointerDown;
  41091. private _lastInteractionTime;
  41092. /**
  41093. * Initializes the behavior.
  41094. */
  41095. init(): void;
  41096. /**
  41097. * Attaches the behavior to its arc rotate camera.
  41098. * @param camera Defines the camera to attach the behavior to
  41099. */
  41100. attach(camera: ArcRotateCamera): void;
  41101. /**
  41102. * Detaches the behavior from its current arc rotate camera.
  41103. */
  41104. detach(): void;
  41105. private _animatables;
  41106. private _betaIsAnimating;
  41107. private _betaTransition;
  41108. private _radiusTransition;
  41109. private _vectorTransition;
  41110. /**
  41111. * Targets the given mesh and updates zoom level accordingly.
  41112. * @param mesh The mesh to target.
  41113. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41114. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41115. */
  41116. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41117. /**
  41118. * Targets the given mesh with its children and updates zoom level accordingly.
  41119. * @param mesh The mesh to target.
  41120. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41121. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41122. */
  41123. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41124. /**
  41125. * Targets the given meshes with their children and updates zoom level accordingly.
  41126. * @param meshes The mesh to target.
  41127. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41128. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41129. */
  41130. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41131. /**
  41132. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  41133. * @param minimumWorld Determines the smaller position of the bounding box extend
  41134. * @param maximumWorld Determines the bigger position of the bounding box extend
  41135. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41136. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41137. */
  41138. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41139. /**
  41140. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  41141. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  41142. * frustum width.
  41143. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  41144. * to fully enclose the mesh in the viewing frustum.
  41145. */
  41146. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  41147. /**
  41148. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  41149. * is automatically returned to its default position (expected to be above ground plane).
  41150. */
  41151. private _maintainCameraAboveGround;
  41152. /**
  41153. * Returns the frustum slope based on the canvas ratio and camera FOV
  41154. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  41155. */
  41156. private _getFrustumSlope;
  41157. /**
  41158. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  41159. */
  41160. private _clearAnimationLocks;
  41161. /**
  41162. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  41163. */
  41164. private _applyUserInteraction;
  41165. /**
  41166. * Stops and removes all animations that have been applied to the camera
  41167. */
  41168. stopAllAnimations(): void;
  41169. /**
  41170. * Gets a value indicating if the user is moving the camera
  41171. */
  41172. get isUserIsMoving(): boolean;
  41173. /**
  41174. * The camera can move all the way towards the mesh.
  41175. */
  41176. static IgnoreBoundsSizeMode: number;
  41177. /**
  41178. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  41179. */
  41180. static FitFrustumSidesMode: number;
  41181. }
  41182. }
  41183. declare module BABYLON {
  41184. /**
  41185. * Base class for Camera Pointer Inputs.
  41186. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  41187. * for example usage.
  41188. */
  41189. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  41190. /**
  41191. * Defines the camera the input is attached to.
  41192. */
  41193. abstract camera: Camera;
  41194. /**
  41195. * Whether keyboard modifier keys are pressed at time of last mouse event.
  41196. */
  41197. protected _altKey: boolean;
  41198. protected _ctrlKey: boolean;
  41199. protected _metaKey: boolean;
  41200. protected _shiftKey: boolean;
  41201. /**
  41202. * Which mouse buttons were pressed at time of last mouse event.
  41203. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  41204. */
  41205. protected _buttonsPressed: number;
  41206. /**
  41207. * Defines the buttons associated with the input to handle camera move.
  41208. */
  41209. buttons: number[];
  41210. /**
  41211. * Attach the input controls to a specific dom element to get the input from.
  41212. * @param element Defines the element the controls should be listened from
  41213. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41214. */
  41215. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41216. /**
  41217. * Detach the current controls from the specified dom element.
  41218. * @param element Defines the element to stop listening the inputs from
  41219. */
  41220. detachControl(element: Nullable<HTMLElement>): void;
  41221. /**
  41222. * Gets the class name of the current input.
  41223. * @returns the class name
  41224. */
  41225. getClassName(): string;
  41226. /**
  41227. * Get the friendly name associated with the input class.
  41228. * @returns the input friendly name
  41229. */
  41230. getSimpleName(): string;
  41231. /**
  41232. * Called on pointer POINTERDOUBLETAP event.
  41233. * Override this method to provide functionality on POINTERDOUBLETAP event.
  41234. */
  41235. protected onDoubleTap(type: string): void;
  41236. /**
  41237. * Called on pointer POINTERMOVE event if only a single touch is active.
  41238. * Override this method to provide functionality.
  41239. */
  41240. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41241. /**
  41242. * Called on pointer POINTERMOVE event if multiple touches are active.
  41243. * Override this method to provide functionality.
  41244. */
  41245. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41246. /**
  41247. * Called on JS contextmenu event.
  41248. * Override this method to provide functionality.
  41249. */
  41250. protected onContextMenu(evt: PointerEvent): void;
  41251. /**
  41252. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41253. * press.
  41254. * Override this method to provide functionality.
  41255. */
  41256. protected onButtonDown(evt: PointerEvent): void;
  41257. /**
  41258. * Called each time a new POINTERUP event occurs. Ie, for each button
  41259. * release.
  41260. * Override this method to provide functionality.
  41261. */
  41262. protected onButtonUp(evt: PointerEvent): void;
  41263. /**
  41264. * Called when window becomes inactive.
  41265. * Override this method to provide functionality.
  41266. */
  41267. protected onLostFocus(): void;
  41268. private _pointerInput;
  41269. private _observer;
  41270. private _onLostFocus;
  41271. private pointA;
  41272. private pointB;
  41273. }
  41274. }
  41275. declare module BABYLON {
  41276. /**
  41277. * Manage the pointers inputs to control an arc rotate camera.
  41278. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41279. */
  41280. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  41281. /**
  41282. * Defines the camera the input is attached to.
  41283. */
  41284. camera: ArcRotateCamera;
  41285. /**
  41286. * Gets the class name of the current input.
  41287. * @returns the class name
  41288. */
  41289. getClassName(): string;
  41290. /**
  41291. * Defines the buttons associated with the input to handle camera move.
  41292. */
  41293. buttons: number[];
  41294. /**
  41295. * Defines the pointer angular sensibility along the X axis or how fast is
  41296. * the camera rotating.
  41297. */
  41298. angularSensibilityX: number;
  41299. /**
  41300. * Defines the pointer angular sensibility along the Y axis or how fast is
  41301. * the camera rotating.
  41302. */
  41303. angularSensibilityY: number;
  41304. /**
  41305. * Defines the pointer pinch precision or how fast is the camera zooming.
  41306. */
  41307. pinchPrecision: number;
  41308. /**
  41309. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41310. * from 0.
  41311. * It defines the percentage of current camera.radius to use as delta when
  41312. * pinch zoom is used.
  41313. */
  41314. pinchDeltaPercentage: number;
  41315. /**
  41316. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  41317. * that any object in the plane at the camera's target point will scale
  41318. * perfectly with finger motion.
  41319. * Overrides pinchDeltaPercentage and pinchPrecision.
  41320. */
  41321. useNaturalPinchZoom: boolean;
  41322. /**
  41323. * Defines the pointer panning sensibility or how fast is the camera moving.
  41324. */
  41325. panningSensibility: number;
  41326. /**
  41327. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  41328. */
  41329. multiTouchPanning: boolean;
  41330. /**
  41331. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  41332. * zoom (pinch) through multitouch.
  41333. */
  41334. multiTouchPanAndZoom: boolean;
  41335. /**
  41336. * Revers pinch action direction.
  41337. */
  41338. pinchInwards: boolean;
  41339. private _isPanClick;
  41340. private _twoFingerActivityCount;
  41341. private _isPinching;
  41342. /**
  41343. * Called on pointer POINTERMOVE event if only a single touch is active.
  41344. */
  41345. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41346. /**
  41347. * Called on pointer POINTERDOUBLETAP event.
  41348. */
  41349. protected onDoubleTap(type: string): void;
  41350. /**
  41351. * Called on pointer POINTERMOVE event if multiple touches are active.
  41352. */
  41353. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41354. /**
  41355. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41356. * press.
  41357. */
  41358. protected onButtonDown(evt: PointerEvent): void;
  41359. /**
  41360. * Called each time a new POINTERUP event occurs. Ie, for each button
  41361. * release.
  41362. */
  41363. protected onButtonUp(evt: PointerEvent): void;
  41364. /**
  41365. * Called when window becomes inactive.
  41366. */
  41367. protected onLostFocus(): void;
  41368. }
  41369. }
  41370. declare module BABYLON {
  41371. /**
  41372. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  41373. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41374. */
  41375. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  41376. /**
  41377. * Defines the camera the input is attached to.
  41378. */
  41379. camera: ArcRotateCamera;
  41380. /**
  41381. * Defines the list of key codes associated with the up action (increase alpha)
  41382. */
  41383. keysUp: number[];
  41384. /**
  41385. * Defines the list of key codes associated with the down action (decrease alpha)
  41386. */
  41387. keysDown: number[];
  41388. /**
  41389. * Defines the list of key codes associated with the left action (increase beta)
  41390. */
  41391. keysLeft: number[];
  41392. /**
  41393. * Defines the list of key codes associated with the right action (decrease beta)
  41394. */
  41395. keysRight: number[];
  41396. /**
  41397. * Defines the list of key codes associated with the reset action.
  41398. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  41399. */
  41400. keysReset: number[];
  41401. /**
  41402. * Defines the panning sensibility of the inputs.
  41403. * (How fast is the camera panning)
  41404. */
  41405. panningSensibility: number;
  41406. /**
  41407. * Defines the zooming sensibility of the inputs.
  41408. * (How fast is the camera zooming)
  41409. */
  41410. zoomingSensibility: number;
  41411. /**
  41412. * Defines whether maintaining the alt key down switch the movement mode from
  41413. * orientation to zoom.
  41414. */
  41415. useAltToZoom: boolean;
  41416. /**
  41417. * Rotation speed of the camera
  41418. */
  41419. angularSpeed: number;
  41420. private _keys;
  41421. private _ctrlPressed;
  41422. private _altPressed;
  41423. private _onCanvasBlurObserver;
  41424. private _onKeyboardObserver;
  41425. private _engine;
  41426. private _scene;
  41427. /**
  41428. * Attach the input controls to a specific dom element to get the input from.
  41429. * @param element Defines the element the controls should be listened from
  41430. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41431. */
  41432. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41433. /**
  41434. * Detach the current controls from the specified dom element.
  41435. * @param element Defines the element to stop listening the inputs from
  41436. */
  41437. detachControl(element: Nullable<HTMLElement>): void;
  41438. /**
  41439. * Update the current camera state depending on the inputs that have been used this frame.
  41440. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41441. */
  41442. checkInputs(): void;
  41443. /**
  41444. * Gets the class name of the current intput.
  41445. * @returns the class name
  41446. */
  41447. getClassName(): string;
  41448. /**
  41449. * Get the friendly name associated with the input class.
  41450. * @returns the input friendly name
  41451. */
  41452. getSimpleName(): string;
  41453. }
  41454. }
  41455. declare module BABYLON {
  41456. /**
  41457. * Manage the mouse wheel inputs to control an arc rotate camera.
  41458. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41459. */
  41460. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  41461. /**
  41462. * Defines the camera the input is attached to.
  41463. */
  41464. camera: ArcRotateCamera;
  41465. /**
  41466. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41467. */
  41468. wheelPrecision: number;
  41469. /**
  41470. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41471. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41472. */
  41473. wheelDeltaPercentage: number;
  41474. private _wheel;
  41475. private _observer;
  41476. private computeDeltaFromMouseWheelLegacyEvent;
  41477. /**
  41478. * Attach the input controls to a specific dom element to get the input from.
  41479. * @param element Defines the element the controls should be listened from
  41480. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41481. */
  41482. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41483. /**
  41484. * Detach the current controls from the specified dom element.
  41485. * @param element Defines the element to stop listening the inputs from
  41486. */
  41487. detachControl(element: Nullable<HTMLElement>): void;
  41488. /**
  41489. * Gets the class name of the current intput.
  41490. * @returns the class name
  41491. */
  41492. getClassName(): string;
  41493. /**
  41494. * Get the friendly name associated with the input class.
  41495. * @returns the input friendly name
  41496. */
  41497. getSimpleName(): string;
  41498. }
  41499. }
  41500. declare module BABYLON {
  41501. /**
  41502. * Default Inputs manager for the ArcRotateCamera.
  41503. * It groups all the default supported inputs for ease of use.
  41504. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41505. */
  41506. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  41507. /**
  41508. * Instantiates a new ArcRotateCameraInputsManager.
  41509. * @param camera Defines the camera the inputs belong to
  41510. */
  41511. constructor(camera: ArcRotateCamera);
  41512. /**
  41513. * Add mouse wheel input support to the input manager.
  41514. * @returns the current input manager
  41515. */
  41516. addMouseWheel(): ArcRotateCameraInputsManager;
  41517. /**
  41518. * Add pointers input support to the input manager.
  41519. * @returns the current input manager
  41520. */
  41521. addPointers(): ArcRotateCameraInputsManager;
  41522. /**
  41523. * Add keyboard input support to the input manager.
  41524. * @returns the current input manager
  41525. */
  41526. addKeyboard(): ArcRotateCameraInputsManager;
  41527. }
  41528. }
  41529. declare module BABYLON {
  41530. /**
  41531. * This represents an orbital type of camera.
  41532. *
  41533. * 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.
  41534. * 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.
  41535. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  41536. */
  41537. export class ArcRotateCamera extends TargetCamera {
  41538. /**
  41539. * Defines the rotation angle of the camera along the longitudinal axis.
  41540. */
  41541. alpha: number;
  41542. /**
  41543. * Defines the rotation angle of the camera along the latitudinal axis.
  41544. */
  41545. beta: number;
  41546. /**
  41547. * Defines the radius of the camera from it s target point.
  41548. */
  41549. radius: number;
  41550. protected _target: Vector3;
  41551. protected _targetHost: Nullable<AbstractMesh>;
  41552. /**
  41553. * Defines the target point of the camera.
  41554. * The camera looks towards it form the radius distance.
  41555. */
  41556. get target(): Vector3;
  41557. set target(value: Vector3);
  41558. /**
  41559. * Define the current local position of the camera in the scene
  41560. */
  41561. get position(): Vector3;
  41562. set position(newPosition: Vector3);
  41563. protected _upVector: Vector3;
  41564. protected _upToYMatrix: Matrix;
  41565. protected _YToUpMatrix: Matrix;
  41566. /**
  41567. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  41568. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  41569. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  41570. */
  41571. set upVector(vec: Vector3);
  41572. get upVector(): Vector3;
  41573. /**
  41574. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  41575. */
  41576. setMatUp(): void;
  41577. /**
  41578. * Current inertia value on the longitudinal axis.
  41579. * The bigger this number the longer it will take for the camera to stop.
  41580. */
  41581. inertialAlphaOffset: number;
  41582. /**
  41583. * Current inertia value on the latitudinal axis.
  41584. * The bigger this number the longer it will take for the camera to stop.
  41585. */
  41586. inertialBetaOffset: number;
  41587. /**
  41588. * Current inertia value on the radius axis.
  41589. * The bigger this number the longer it will take for the camera to stop.
  41590. */
  41591. inertialRadiusOffset: number;
  41592. /**
  41593. * Minimum allowed angle on the longitudinal axis.
  41594. * This can help limiting how the Camera is able to move in the scene.
  41595. */
  41596. lowerAlphaLimit: Nullable<number>;
  41597. /**
  41598. * Maximum allowed angle on the longitudinal axis.
  41599. * This can help limiting how the Camera is able to move in the scene.
  41600. */
  41601. upperAlphaLimit: Nullable<number>;
  41602. /**
  41603. * Minimum allowed angle on the latitudinal axis.
  41604. * This can help limiting how the Camera is able to move in the scene.
  41605. */
  41606. lowerBetaLimit: number;
  41607. /**
  41608. * Maximum allowed angle on the latitudinal axis.
  41609. * This can help limiting how the Camera is able to move in the scene.
  41610. */
  41611. upperBetaLimit: number;
  41612. /**
  41613. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  41614. * This can help limiting how the Camera is able to move in the scene.
  41615. */
  41616. lowerRadiusLimit: Nullable<number>;
  41617. /**
  41618. * Maximum allowed distance of the camera to the target (The camera can not get further).
  41619. * This can help limiting how the Camera is able to move in the scene.
  41620. */
  41621. upperRadiusLimit: Nullable<number>;
  41622. /**
  41623. * Defines the current inertia value used during panning of the camera along the X axis.
  41624. */
  41625. inertialPanningX: number;
  41626. /**
  41627. * Defines the current inertia value used during panning of the camera along the Y axis.
  41628. */
  41629. inertialPanningY: number;
  41630. /**
  41631. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  41632. * Basically if your fingers moves away from more than this distance you will be considered
  41633. * in pinch mode.
  41634. */
  41635. pinchToPanMaxDistance: number;
  41636. /**
  41637. * Defines the maximum distance the camera can pan.
  41638. * This could help keeping the cammera always in your scene.
  41639. */
  41640. panningDistanceLimit: Nullable<number>;
  41641. /**
  41642. * Defines the target of the camera before paning.
  41643. */
  41644. panningOriginTarget: Vector3;
  41645. /**
  41646. * Defines the value of the inertia used during panning.
  41647. * 0 would mean stop inertia and one would mean no decelleration at all.
  41648. */
  41649. panningInertia: number;
  41650. /**
  41651. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  41652. */
  41653. get angularSensibilityX(): number;
  41654. set angularSensibilityX(value: number);
  41655. /**
  41656. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  41657. */
  41658. get angularSensibilityY(): number;
  41659. set angularSensibilityY(value: number);
  41660. /**
  41661. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  41662. */
  41663. get pinchPrecision(): number;
  41664. set pinchPrecision(value: number);
  41665. /**
  41666. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  41667. * It will be used instead of pinchDeltaPrecision if different from 0.
  41668. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41669. */
  41670. get pinchDeltaPercentage(): number;
  41671. set pinchDeltaPercentage(value: number);
  41672. /**
  41673. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  41674. * and pinch delta percentage.
  41675. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  41676. * that any object in the plane at the camera's target point will scale
  41677. * perfectly with finger motion.
  41678. */
  41679. get useNaturalPinchZoom(): boolean;
  41680. set useNaturalPinchZoom(value: boolean);
  41681. /**
  41682. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  41683. */
  41684. get panningSensibility(): number;
  41685. set panningSensibility(value: number);
  41686. /**
  41687. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  41688. */
  41689. get keysUp(): number[];
  41690. set keysUp(value: number[]);
  41691. /**
  41692. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  41693. */
  41694. get keysDown(): number[];
  41695. set keysDown(value: number[]);
  41696. /**
  41697. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  41698. */
  41699. get keysLeft(): number[];
  41700. set keysLeft(value: number[]);
  41701. /**
  41702. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  41703. */
  41704. get keysRight(): number[];
  41705. set keysRight(value: number[]);
  41706. /**
  41707. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41708. */
  41709. get wheelPrecision(): number;
  41710. set wheelPrecision(value: number);
  41711. /**
  41712. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  41713. * It will be used instead of pinchDeltaPrecision if different from 0.
  41714. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41715. */
  41716. get wheelDeltaPercentage(): number;
  41717. set wheelDeltaPercentage(value: number);
  41718. /**
  41719. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  41720. */
  41721. zoomOnFactor: number;
  41722. /**
  41723. * Defines a screen offset for the camera position.
  41724. */
  41725. targetScreenOffset: Vector2;
  41726. /**
  41727. * Allows the camera to be completely reversed.
  41728. * If false the camera can not arrive upside down.
  41729. */
  41730. allowUpsideDown: boolean;
  41731. /**
  41732. * Define if double tap/click is used to restore the previously saved state of the camera.
  41733. */
  41734. useInputToRestoreState: boolean;
  41735. /** @hidden */
  41736. _viewMatrix: Matrix;
  41737. /** @hidden */
  41738. _useCtrlForPanning: boolean;
  41739. /** @hidden */
  41740. _panningMouseButton: number;
  41741. /**
  41742. * Defines the input associated to the camera.
  41743. */
  41744. inputs: ArcRotateCameraInputsManager;
  41745. /** @hidden */
  41746. _reset: () => void;
  41747. /**
  41748. * Defines the allowed panning axis.
  41749. */
  41750. panningAxis: Vector3;
  41751. protected _localDirection: Vector3;
  41752. protected _transformedDirection: Vector3;
  41753. private _bouncingBehavior;
  41754. /**
  41755. * Gets the bouncing behavior of the camera if it has been enabled.
  41756. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  41757. */
  41758. get bouncingBehavior(): Nullable<BouncingBehavior>;
  41759. /**
  41760. * Defines if the bouncing behavior of the camera is enabled on the camera.
  41761. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  41762. */
  41763. get useBouncingBehavior(): boolean;
  41764. set useBouncingBehavior(value: boolean);
  41765. private _framingBehavior;
  41766. /**
  41767. * Gets the framing behavior of the camera if it has been enabled.
  41768. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41769. */
  41770. get framingBehavior(): Nullable<FramingBehavior>;
  41771. /**
  41772. * Defines if the framing behavior of the camera is enabled on the camera.
  41773. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41774. */
  41775. get useFramingBehavior(): boolean;
  41776. set useFramingBehavior(value: boolean);
  41777. private _autoRotationBehavior;
  41778. /**
  41779. * Gets the auto rotation behavior of the camera if it has been enabled.
  41780. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  41781. */
  41782. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  41783. /**
  41784. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  41785. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  41786. */
  41787. get useAutoRotationBehavior(): boolean;
  41788. set useAutoRotationBehavior(value: boolean);
  41789. /**
  41790. * Observable triggered when the mesh target has been changed on the camera.
  41791. */
  41792. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  41793. /**
  41794. * Event raised when the camera is colliding with a mesh.
  41795. */
  41796. onCollide: (collidedMesh: AbstractMesh) => void;
  41797. /**
  41798. * Defines whether the camera should check collision with the objects oh the scene.
  41799. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  41800. */
  41801. checkCollisions: boolean;
  41802. /**
  41803. * Defines the collision radius of the camera.
  41804. * This simulates a sphere around the camera.
  41805. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41806. */
  41807. collisionRadius: Vector3;
  41808. protected _collider: Collider;
  41809. protected _previousPosition: Vector3;
  41810. protected _collisionVelocity: Vector3;
  41811. protected _newPosition: Vector3;
  41812. protected _previousAlpha: number;
  41813. protected _previousBeta: number;
  41814. protected _previousRadius: number;
  41815. protected _collisionTriggered: boolean;
  41816. protected _targetBoundingCenter: Nullable<Vector3>;
  41817. private _computationVector;
  41818. /**
  41819. * Instantiates a new ArcRotateCamera in a given scene
  41820. * @param name Defines the name of the camera
  41821. * @param alpha Defines the camera rotation along the logitudinal axis
  41822. * @param beta Defines the camera rotation along the latitudinal axis
  41823. * @param radius Defines the camera distance from its target
  41824. * @param target Defines the camera target
  41825. * @param scene Defines the scene the camera belongs to
  41826. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  41827. */
  41828. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41829. /** @hidden */
  41830. _initCache(): void;
  41831. /** @hidden */
  41832. _updateCache(ignoreParentClass?: boolean): void;
  41833. protected _getTargetPosition(): Vector3;
  41834. private _storedAlpha;
  41835. private _storedBeta;
  41836. private _storedRadius;
  41837. private _storedTarget;
  41838. private _storedTargetScreenOffset;
  41839. /**
  41840. * Stores the current state of the camera (alpha, beta, radius and target)
  41841. * @returns the camera itself
  41842. */
  41843. storeState(): Camera;
  41844. /**
  41845. * @hidden
  41846. * Restored camera state. You must call storeState() first
  41847. */
  41848. _restoreStateValues(): boolean;
  41849. /** @hidden */
  41850. _isSynchronizedViewMatrix(): boolean;
  41851. /**
  41852. * Attached controls to the current camera.
  41853. * @param element Defines the element the controls should be listened from
  41854. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41855. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  41856. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  41857. */
  41858. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  41859. /**
  41860. * Detach the current controls from the camera.
  41861. * The camera will stop reacting to inputs.
  41862. * @param element Defines the element to stop listening the inputs from
  41863. */
  41864. detachControl(element: HTMLElement): void;
  41865. /** @hidden */
  41866. _checkInputs(): void;
  41867. protected _checkLimits(): void;
  41868. /**
  41869. * Rebuilds angles (alpha, beta) and radius from the give position and target
  41870. */
  41871. rebuildAnglesAndRadius(): void;
  41872. /**
  41873. * Use a position to define the current camera related information like alpha, beta and radius
  41874. * @param position Defines the position to set the camera at
  41875. */
  41876. setPosition(position: Vector3): void;
  41877. /**
  41878. * Defines the target the camera should look at.
  41879. * This will automatically adapt alpha beta and radius to fit within the new target.
  41880. * @param target Defines the new target as a Vector or a mesh
  41881. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  41882. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  41883. */
  41884. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  41885. /** @hidden */
  41886. _getViewMatrix(): Matrix;
  41887. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  41888. /**
  41889. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  41890. * @param meshes Defines the mesh to zoom on
  41891. * @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)
  41892. */
  41893. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  41894. /**
  41895. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  41896. * The target will be changed but the radius
  41897. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  41898. * @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)
  41899. */
  41900. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  41901. min: Vector3;
  41902. max: Vector3;
  41903. distance: number;
  41904. }, doNotUpdateMaxZ?: boolean): void;
  41905. /**
  41906. * @override
  41907. * Override Camera.createRigCamera
  41908. */
  41909. createRigCamera(name: string, cameraIndex: number): Camera;
  41910. /**
  41911. * @hidden
  41912. * @override
  41913. * Override Camera._updateRigCameras
  41914. */
  41915. _updateRigCameras(): void;
  41916. /**
  41917. * Destroy the camera and release the current resources hold by it.
  41918. */
  41919. dispose(): void;
  41920. /**
  41921. * Gets the current object class name.
  41922. * @return the class name
  41923. */
  41924. getClassName(): string;
  41925. }
  41926. }
  41927. declare module BABYLON {
  41928. /**
  41929. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  41930. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  41931. */
  41932. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  41933. /**
  41934. * Gets the name of the behavior.
  41935. */
  41936. get name(): string;
  41937. private _zoomStopsAnimation;
  41938. private _idleRotationSpeed;
  41939. private _idleRotationWaitTime;
  41940. private _idleRotationSpinupTime;
  41941. /**
  41942. * Sets the flag that indicates if user zooming should stop animation.
  41943. */
  41944. set zoomStopsAnimation(flag: boolean);
  41945. /**
  41946. * Gets the flag that indicates if user zooming should stop animation.
  41947. */
  41948. get zoomStopsAnimation(): boolean;
  41949. /**
  41950. * Sets the default speed at which the camera rotates around the model.
  41951. */
  41952. set idleRotationSpeed(speed: number);
  41953. /**
  41954. * Gets the default speed at which the camera rotates around the model.
  41955. */
  41956. get idleRotationSpeed(): number;
  41957. /**
  41958. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  41959. */
  41960. set idleRotationWaitTime(time: number);
  41961. /**
  41962. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  41963. */
  41964. get idleRotationWaitTime(): number;
  41965. /**
  41966. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  41967. */
  41968. set idleRotationSpinupTime(time: number);
  41969. /**
  41970. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  41971. */
  41972. get idleRotationSpinupTime(): number;
  41973. /**
  41974. * Gets a value indicating if the camera is currently rotating because of this behavior
  41975. */
  41976. get rotationInProgress(): boolean;
  41977. private _onPrePointerObservableObserver;
  41978. private _onAfterCheckInputsObserver;
  41979. private _attachedCamera;
  41980. private _isPointerDown;
  41981. private _lastFrameTime;
  41982. private _lastInteractionTime;
  41983. private _cameraRotationSpeed;
  41984. /**
  41985. * Initializes the behavior.
  41986. */
  41987. init(): void;
  41988. /**
  41989. * Attaches the behavior to its arc rotate camera.
  41990. * @param camera Defines the camera to attach the behavior to
  41991. */
  41992. attach(camera: ArcRotateCamera): void;
  41993. /**
  41994. * Detaches the behavior from its current arc rotate camera.
  41995. */
  41996. detach(): void;
  41997. /**
  41998. * Returns true if user is scrolling.
  41999. * @return true if user is scrolling.
  42000. */
  42001. private _userIsZooming;
  42002. private _lastFrameRadius;
  42003. private _shouldAnimationStopForInteraction;
  42004. /**
  42005. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42006. */
  42007. private _applyUserInteraction;
  42008. private _userIsMoving;
  42009. }
  42010. }
  42011. declare module BABYLON {
  42012. /**
  42013. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  42014. */
  42015. export class AttachToBoxBehavior implements Behavior<Mesh> {
  42016. private ui;
  42017. /**
  42018. * The name of the behavior
  42019. */
  42020. name: string;
  42021. /**
  42022. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  42023. */
  42024. distanceAwayFromFace: number;
  42025. /**
  42026. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  42027. */
  42028. distanceAwayFromBottomOfFace: number;
  42029. private _faceVectors;
  42030. private _target;
  42031. private _scene;
  42032. private _onRenderObserver;
  42033. private _tmpMatrix;
  42034. private _tmpVector;
  42035. /**
  42036. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  42037. * @param ui The transform node that should be attched to the mesh
  42038. */
  42039. constructor(ui: TransformNode);
  42040. /**
  42041. * Initializes the behavior
  42042. */
  42043. init(): void;
  42044. private _closestFace;
  42045. private _zeroVector;
  42046. private _lookAtTmpMatrix;
  42047. private _lookAtToRef;
  42048. /**
  42049. * Attaches the AttachToBoxBehavior to the passed in mesh
  42050. * @param target The mesh that the specified node will be attached to
  42051. */
  42052. attach(target: Mesh): void;
  42053. /**
  42054. * Detaches the behavior from the mesh
  42055. */
  42056. detach(): void;
  42057. }
  42058. }
  42059. declare module BABYLON {
  42060. /**
  42061. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  42062. */
  42063. export class FadeInOutBehavior implements Behavior<Mesh> {
  42064. /**
  42065. * Time in milliseconds to delay before fading in (Default: 0)
  42066. */
  42067. delay: number;
  42068. /**
  42069. * Time in milliseconds for the mesh to fade in (Default: 300)
  42070. */
  42071. fadeInTime: number;
  42072. private _millisecondsPerFrame;
  42073. private _hovered;
  42074. private _hoverValue;
  42075. private _ownerNode;
  42076. /**
  42077. * Instatiates the FadeInOutBehavior
  42078. */
  42079. constructor();
  42080. /**
  42081. * The name of the behavior
  42082. */
  42083. get name(): string;
  42084. /**
  42085. * Initializes the behavior
  42086. */
  42087. init(): void;
  42088. /**
  42089. * Attaches the fade behavior on the passed in mesh
  42090. * @param ownerNode The mesh that will be faded in/out once attached
  42091. */
  42092. attach(ownerNode: Mesh): void;
  42093. /**
  42094. * Detaches the behavior from the mesh
  42095. */
  42096. detach(): void;
  42097. /**
  42098. * Triggers the mesh to begin fading in or out
  42099. * @param value if the object should fade in or out (true to fade in)
  42100. */
  42101. fadeIn(value: boolean): void;
  42102. private _update;
  42103. private _setAllVisibility;
  42104. }
  42105. }
  42106. declare module BABYLON {
  42107. /**
  42108. * Class containing a set of static utilities functions for managing Pivots
  42109. * @hidden
  42110. */
  42111. export class PivotTools {
  42112. private static _PivotCached;
  42113. private static _OldPivotPoint;
  42114. private static _PivotTranslation;
  42115. private static _PivotTmpVector;
  42116. /** @hidden */
  42117. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  42118. /** @hidden */
  42119. static _RestorePivotPoint(mesh: AbstractMesh): void;
  42120. }
  42121. }
  42122. declare module BABYLON {
  42123. /**
  42124. * Class containing static functions to help procedurally build meshes
  42125. */
  42126. export class PlaneBuilder {
  42127. /**
  42128. * Creates a plane mesh
  42129. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  42130. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  42131. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  42132. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42133. * * 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
  42134. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42135. * @param name defines the name of the mesh
  42136. * @param options defines the options used to create the mesh
  42137. * @param scene defines the hosting scene
  42138. * @returns the plane mesh
  42139. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  42140. */
  42141. static CreatePlane(name: string, options: {
  42142. size?: number;
  42143. width?: number;
  42144. height?: number;
  42145. sideOrientation?: number;
  42146. frontUVs?: Vector4;
  42147. backUVs?: Vector4;
  42148. updatable?: boolean;
  42149. sourcePlane?: Plane;
  42150. }, scene?: Nullable<Scene>): Mesh;
  42151. }
  42152. }
  42153. declare module BABYLON {
  42154. /**
  42155. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  42156. */
  42157. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  42158. private static _AnyMouseID;
  42159. /**
  42160. * Abstract mesh the behavior is set on
  42161. */
  42162. attachedNode: AbstractMesh;
  42163. private _dragPlane;
  42164. private _scene;
  42165. private _pointerObserver;
  42166. private _beforeRenderObserver;
  42167. private static _planeScene;
  42168. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  42169. /**
  42170. * 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)
  42171. */
  42172. maxDragAngle: number;
  42173. /**
  42174. * @hidden
  42175. */
  42176. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  42177. /**
  42178. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42179. */
  42180. currentDraggingPointerID: number;
  42181. /**
  42182. * The last position where the pointer hit the drag plane in world space
  42183. */
  42184. lastDragPosition: Vector3;
  42185. /**
  42186. * If the behavior is currently in a dragging state
  42187. */
  42188. dragging: boolean;
  42189. /**
  42190. * 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)
  42191. */
  42192. dragDeltaRatio: number;
  42193. /**
  42194. * If the drag plane orientation should be updated during the dragging (Default: true)
  42195. */
  42196. updateDragPlane: boolean;
  42197. private _debugMode;
  42198. private _moving;
  42199. /**
  42200. * Fires each time the attached mesh is dragged with the pointer
  42201. * * delta between last drag position and current drag position in world space
  42202. * * dragDistance along the drag axis
  42203. * * dragPlaneNormal normal of the current drag plane used during the drag
  42204. * * dragPlanePoint in world space where the drag intersects the drag plane
  42205. */
  42206. onDragObservable: Observable<{
  42207. delta: Vector3;
  42208. dragPlanePoint: Vector3;
  42209. dragPlaneNormal: Vector3;
  42210. dragDistance: number;
  42211. pointerId: number;
  42212. }>;
  42213. /**
  42214. * Fires each time a drag begins (eg. mouse down on mesh)
  42215. */
  42216. onDragStartObservable: Observable<{
  42217. dragPlanePoint: Vector3;
  42218. pointerId: number;
  42219. }>;
  42220. /**
  42221. * Fires each time a drag ends (eg. mouse release after drag)
  42222. */
  42223. onDragEndObservable: Observable<{
  42224. dragPlanePoint: Vector3;
  42225. pointerId: number;
  42226. }>;
  42227. /**
  42228. * If the attached mesh should be moved when dragged
  42229. */
  42230. moveAttached: boolean;
  42231. /**
  42232. * If the drag behavior will react to drag events (Default: true)
  42233. */
  42234. enabled: boolean;
  42235. /**
  42236. * If pointer events should start and release the drag (Default: true)
  42237. */
  42238. startAndReleaseDragOnPointerEvents: boolean;
  42239. /**
  42240. * If camera controls should be detached during the drag
  42241. */
  42242. detachCameraControls: boolean;
  42243. /**
  42244. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  42245. */
  42246. useObjectOrientationForDragging: boolean;
  42247. private _options;
  42248. /**
  42249. * Gets the options used by the behavior
  42250. */
  42251. get options(): {
  42252. dragAxis?: Vector3;
  42253. dragPlaneNormal?: Vector3;
  42254. };
  42255. /**
  42256. * Sets the options used by the behavior
  42257. */
  42258. set options(options: {
  42259. dragAxis?: Vector3;
  42260. dragPlaneNormal?: Vector3;
  42261. });
  42262. /**
  42263. * Creates a pointer drag behavior that can be attached to a mesh
  42264. * @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)
  42265. */
  42266. constructor(options?: {
  42267. dragAxis?: Vector3;
  42268. dragPlaneNormal?: Vector3;
  42269. });
  42270. /**
  42271. * Predicate to determine if it is valid to move the object to a new position when it is moved
  42272. */
  42273. validateDrag: (targetPosition: Vector3) => boolean;
  42274. /**
  42275. * The name of the behavior
  42276. */
  42277. get name(): string;
  42278. /**
  42279. * Initializes the behavior
  42280. */
  42281. init(): void;
  42282. private _tmpVector;
  42283. private _alternatePickedPoint;
  42284. private _worldDragAxis;
  42285. private _targetPosition;
  42286. private _attachedElement;
  42287. /**
  42288. * Attaches the drag behavior the passed in mesh
  42289. * @param ownerNode The mesh that will be dragged around once attached
  42290. * @param predicate Predicate to use for pick filtering
  42291. */
  42292. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  42293. /**
  42294. * Force relase the drag action by code.
  42295. */
  42296. releaseDrag(): void;
  42297. private _startDragRay;
  42298. private _lastPointerRay;
  42299. /**
  42300. * Simulates the start of a pointer drag event on the behavior
  42301. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  42302. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  42303. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  42304. */
  42305. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  42306. private _startDrag;
  42307. private _dragDelta;
  42308. private _moveDrag;
  42309. private _pickWithRayOnDragPlane;
  42310. private _pointA;
  42311. private _pointB;
  42312. private _pointC;
  42313. private _lineA;
  42314. private _lineB;
  42315. private _localAxis;
  42316. private _lookAt;
  42317. private _updateDragPlanePosition;
  42318. /**
  42319. * Detaches the behavior from the mesh
  42320. */
  42321. detach(): void;
  42322. }
  42323. }
  42324. declare module BABYLON {
  42325. /**
  42326. * A behavior that when attached to a mesh will allow the mesh to be scaled
  42327. */
  42328. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  42329. private _dragBehaviorA;
  42330. private _dragBehaviorB;
  42331. private _startDistance;
  42332. private _initialScale;
  42333. private _targetScale;
  42334. private _ownerNode;
  42335. private _sceneRenderObserver;
  42336. /**
  42337. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  42338. */
  42339. constructor();
  42340. /**
  42341. * The name of the behavior
  42342. */
  42343. get name(): string;
  42344. /**
  42345. * Initializes the behavior
  42346. */
  42347. init(): void;
  42348. private _getCurrentDistance;
  42349. /**
  42350. * Attaches the scale behavior the passed in mesh
  42351. * @param ownerNode The mesh that will be scaled around once attached
  42352. */
  42353. attach(ownerNode: Mesh): void;
  42354. /**
  42355. * Detaches the behavior from the mesh
  42356. */
  42357. detach(): void;
  42358. }
  42359. }
  42360. declare module BABYLON {
  42361. /**
  42362. * 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
  42363. */
  42364. export class SixDofDragBehavior implements Behavior<Mesh> {
  42365. private static _virtualScene;
  42366. private _ownerNode;
  42367. private _sceneRenderObserver;
  42368. private _scene;
  42369. private _targetPosition;
  42370. private _virtualOriginMesh;
  42371. private _virtualDragMesh;
  42372. private _pointerObserver;
  42373. private _moving;
  42374. private _startingOrientation;
  42375. private _attachedElement;
  42376. /**
  42377. * 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)
  42378. */
  42379. private zDragFactor;
  42380. /**
  42381. * If the object should rotate to face the drag origin
  42382. */
  42383. rotateDraggedObject: boolean;
  42384. /**
  42385. * If the behavior is currently in a dragging state
  42386. */
  42387. dragging: boolean;
  42388. /**
  42389. * 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)
  42390. */
  42391. dragDeltaRatio: number;
  42392. /**
  42393. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42394. */
  42395. currentDraggingPointerID: number;
  42396. /**
  42397. * If camera controls should be detached during the drag
  42398. */
  42399. detachCameraControls: boolean;
  42400. /**
  42401. * Fires each time a drag starts
  42402. */
  42403. onDragStartObservable: Observable<{}>;
  42404. /**
  42405. * Fires each time a drag ends (eg. mouse release after drag)
  42406. */
  42407. onDragEndObservable: Observable<{}>;
  42408. /**
  42409. * 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
  42410. */
  42411. constructor();
  42412. /**
  42413. * The name of the behavior
  42414. */
  42415. get name(): string;
  42416. /**
  42417. * Initializes the behavior
  42418. */
  42419. init(): void;
  42420. /**
  42421. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  42422. */
  42423. private get _pointerCamera();
  42424. /**
  42425. * Attaches the scale behavior the passed in mesh
  42426. * @param ownerNode The mesh that will be scaled around once attached
  42427. */
  42428. attach(ownerNode: Mesh): void;
  42429. /**
  42430. * Detaches the behavior from the mesh
  42431. */
  42432. detach(): void;
  42433. }
  42434. }
  42435. declare module BABYLON {
  42436. /**
  42437. * Class used to apply inverse kinematics to bones
  42438. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  42439. */
  42440. export class BoneIKController {
  42441. private static _tmpVecs;
  42442. private static _tmpQuat;
  42443. private static _tmpMats;
  42444. /**
  42445. * Gets or sets the target mesh
  42446. */
  42447. targetMesh: AbstractMesh;
  42448. /** Gets or sets the mesh used as pole */
  42449. poleTargetMesh: AbstractMesh;
  42450. /**
  42451. * Gets or sets the bone used as pole
  42452. */
  42453. poleTargetBone: Nullable<Bone>;
  42454. /**
  42455. * Gets or sets the target position
  42456. */
  42457. targetPosition: Vector3;
  42458. /**
  42459. * Gets or sets the pole target position
  42460. */
  42461. poleTargetPosition: Vector3;
  42462. /**
  42463. * Gets or sets the pole target local offset
  42464. */
  42465. poleTargetLocalOffset: Vector3;
  42466. /**
  42467. * Gets or sets the pole angle
  42468. */
  42469. poleAngle: number;
  42470. /**
  42471. * Gets or sets the mesh associated with the controller
  42472. */
  42473. mesh: AbstractMesh;
  42474. /**
  42475. * 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)
  42476. */
  42477. slerpAmount: number;
  42478. private _bone1Quat;
  42479. private _bone1Mat;
  42480. private _bone2Ang;
  42481. private _bone1;
  42482. private _bone2;
  42483. private _bone1Length;
  42484. private _bone2Length;
  42485. private _maxAngle;
  42486. private _maxReach;
  42487. private _rightHandedSystem;
  42488. private _bendAxis;
  42489. private _slerping;
  42490. private _adjustRoll;
  42491. /**
  42492. * Gets or sets maximum allowed angle
  42493. */
  42494. get maxAngle(): number;
  42495. set maxAngle(value: number);
  42496. /**
  42497. * Creates a new BoneIKController
  42498. * @param mesh defines the mesh to control
  42499. * @param bone defines the bone to control
  42500. * @param options defines options to set up the controller
  42501. */
  42502. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  42503. targetMesh?: AbstractMesh;
  42504. poleTargetMesh?: AbstractMesh;
  42505. poleTargetBone?: Bone;
  42506. poleTargetLocalOffset?: Vector3;
  42507. poleAngle?: number;
  42508. bendAxis?: Vector3;
  42509. maxAngle?: number;
  42510. slerpAmount?: number;
  42511. });
  42512. private _setMaxAngle;
  42513. /**
  42514. * Force the controller to update the bones
  42515. */
  42516. update(): void;
  42517. }
  42518. }
  42519. declare module BABYLON {
  42520. /**
  42521. * Class used to make a bone look toward a point in space
  42522. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  42523. */
  42524. export class BoneLookController {
  42525. private static _tmpVecs;
  42526. private static _tmpQuat;
  42527. private static _tmpMats;
  42528. /**
  42529. * The target Vector3 that the bone will look at
  42530. */
  42531. target: Vector3;
  42532. /**
  42533. * The mesh that the bone is attached to
  42534. */
  42535. mesh: AbstractMesh;
  42536. /**
  42537. * The bone that will be looking to the target
  42538. */
  42539. bone: Bone;
  42540. /**
  42541. * The up axis of the coordinate system that is used when the bone is rotated
  42542. */
  42543. upAxis: Vector3;
  42544. /**
  42545. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  42546. */
  42547. upAxisSpace: Space;
  42548. /**
  42549. * Used to make an adjustment to the yaw of the bone
  42550. */
  42551. adjustYaw: number;
  42552. /**
  42553. * Used to make an adjustment to the pitch of the bone
  42554. */
  42555. adjustPitch: number;
  42556. /**
  42557. * Used to make an adjustment to the roll of the bone
  42558. */
  42559. adjustRoll: number;
  42560. /**
  42561. * 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)
  42562. */
  42563. slerpAmount: number;
  42564. private _minYaw;
  42565. private _maxYaw;
  42566. private _minPitch;
  42567. private _maxPitch;
  42568. private _minYawSin;
  42569. private _minYawCos;
  42570. private _maxYawSin;
  42571. private _maxYawCos;
  42572. private _midYawConstraint;
  42573. private _minPitchTan;
  42574. private _maxPitchTan;
  42575. private _boneQuat;
  42576. private _slerping;
  42577. private _transformYawPitch;
  42578. private _transformYawPitchInv;
  42579. private _firstFrameSkipped;
  42580. private _yawRange;
  42581. private _fowardAxis;
  42582. /**
  42583. * Gets or sets the minimum yaw angle that the bone can look to
  42584. */
  42585. get minYaw(): number;
  42586. set minYaw(value: number);
  42587. /**
  42588. * Gets or sets the maximum yaw angle that the bone can look to
  42589. */
  42590. get maxYaw(): number;
  42591. set maxYaw(value: number);
  42592. /**
  42593. * Gets or sets the minimum pitch angle that the bone can look to
  42594. */
  42595. get minPitch(): number;
  42596. set minPitch(value: number);
  42597. /**
  42598. * Gets or sets the maximum pitch angle that the bone can look to
  42599. */
  42600. get maxPitch(): number;
  42601. set maxPitch(value: number);
  42602. /**
  42603. * Create a BoneLookController
  42604. * @param mesh the mesh that the bone belongs to
  42605. * @param bone the bone that will be looking to the target
  42606. * @param target the target Vector3 to look at
  42607. * @param options optional settings:
  42608. * * maxYaw: the maximum angle the bone will yaw to
  42609. * * minYaw: the minimum angle the bone will yaw to
  42610. * * maxPitch: the maximum angle the bone will pitch to
  42611. * * minPitch: the minimum angle the bone will yaw to
  42612. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  42613. * * upAxis: the up axis of the coordinate system
  42614. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  42615. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  42616. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  42617. * * adjustYaw: used to make an adjustment to the yaw of the bone
  42618. * * adjustPitch: used to make an adjustment to the pitch of the bone
  42619. * * adjustRoll: used to make an adjustment to the roll of the bone
  42620. **/
  42621. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  42622. maxYaw?: number;
  42623. minYaw?: number;
  42624. maxPitch?: number;
  42625. minPitch?: number;
  42626. slerpAmount?: number;
  42627. upAxis?: Vector3;
  42628. upAxisSpace?: Space;
  42629. yawAxis?: Vector3;
  42630. pitchAxis?: Vector3;
  42631. adjustYaw?: number;
  42632. adjustPitch?: number;
  42633. adjustRoll?: number;
  42634. });
  42635. /**
  42636. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  42637. */
  42638. update(): void;
  42639. private _getAngleDiff;
  42640. private _getAngleBetween;
  42641. private _isAngleBetween;
  42642. }
  42643. }
  42644. declare module BABYLON {
  42645. /**
  42646. * Manage the gamepad inputs to control an arc rotate camera.
  42647. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42648. */
  42649. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  42650. /**
  42651. * Defines the camera the input is attached to.
  42652. */
  42653. camera: ArcRotateCamera;
  42654. /**
  42655. * Defines the gamepad the input is gathering event from.
  42656. */
  42657. gamepad: Nullable<Gamepad>;
  42658. /**
  42659. * Defines the gamepad rotation sensiblity.
  42660. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42661. */
  42662. gamepadRotationSensibility: number;
  42663. /**
  42664. * Defines the gamepad move sensiblity.
  42665. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42666. */
  42667. gamepadMoveSensibility: number;
  42668. private _yAxisScale;
  42669. /**
  42670. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  42671. */
  42672. get invertYAxis(): boolean;
  42673. set invertYAxis(value: boolean);
  42674. private _onGamepadConnectedObserver;
  42675. private _onGamepadDisconnectedObserver;
  42676. /**
  42677. * Attach the input controls to a specific dom element to get the input from.
  42678. * @param element Defines the element the controls should be listened from
  42679. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42680. */
  42681. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42682. /**
  42683. * Detach the current controls from the specified dom element.
  42684. * @param element Defines the element to stop listening the inputs from
  42685. */
  42686. detachControl(element: Nullable<HTMLElement>): void;
  42687. /**
  42688. * Update the current camera state depending on the inputs that have been used this frame.
  42689. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42690. */
  42691. checkInputs(): void;
  42692. /**
  42693. * Gets the class name of the current intput.
  42694. * @returns the class name
  42695. */
  42696. getClassName(): string;
  42697. /**
  42698. * Get the friendly name associated with the input class.
  42699. * @returns the input friendly name
  42700. */
  42701. getSimpleName(): string;
  42702. }
  42703. }
  42704. declare module BABYLON {
  42705. interface ArcRotateCameraInputsManager {
  42706. /**
  42707. * Add orientation input support to the input manager.
  42708. * @returns the current input manager
  42709. */
  42710. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  42711. }
  42712. /**
  42713. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  42714. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42715. */
  42716. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  42717. /**
  42718. * Defines the camera the input is attached to.
  42719. */
  42720. camera: ArcRotateCamera;
  42721. /**
  42722. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  42723. */
  42724. alphaCorrection: number;
  42725. /**
  42726. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  42727. */
  42728. gammaCorrection: number;
  42729. private _alpha;
  42730. private _gamma;
  42731. private _dirty;
  42732. private _deviceOrientationHandler;
  42733. /**
  42734. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  42735. */
  42736. constructor();
  42737. /**
  42738. * Attach the input controls to a specific dom element to get the input from.
  42739. * @param element Defines the element the controls should be listened from
  42740. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42741. */
  42742. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42743. /** @hidden */
  42744. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  42745. /**
  42746. * Update the current camera state depending on the inputs that have been used this frame.
  42747. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42748. */
  42749. checkInputs(): void;
  42750. /**
  42751. * Detach the current controls from the specified dom element.
  42752. * @param element Defines the element to stop listening the inputs from
  42753. */
  42754. detachControl(element: Nullable<HTMLElement>): void;
  42755. /**
  42756. * Gets the class name of the current intput.
  42757. * @returns the class name
  42758. */
  42759. getClassName(): string;
  42760. /**
  42761. * Get the friendly name associated with the input class.
  42762. * @returns the input friendly name
  42763. */
  42764. getSimpleName(): string;
  42765. }
  42766. }
  42767. declare module BABYLON {
  42768. /**
  42769. * Listen to mouse events to control the camera.
  42770. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42771. */
  42772. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  42773. /**
  42774. * Defines the camera the input is attached to.
  42775. */
  42776. camera: FlyCamera;
  42777. /**
  42778. * Defines if touch is enabled. (Default is true.)
  42779. */
  42780. touchEnabled: boolean;
  42781. /**
  42782. * Defines the buttons associated with the input to handle camera rotation.
  42783. */
  42784. buttons: number[];
  42785. /**
  42786. * Assign buttons for Yaw control.
  42787. */
  42788. buttonsYaw: number[];
  42789. /**
  42790. * Assign buttons for Pitch control.
  42791. */
  42792. buttonsPitch: number[];
  42793. /**
  42794. * Assign buttons for Roll control.
  42795. */
  42796. buttonsRoll: number[];
  42797. /**
  42798. * Detect if any button is being pressed while mouse is moved.
  42799. * -1 = Mouse locked.
  42800. * 0 = Left button.
  42801. * 1 = Middle Button.
  42802. * 2 = Right Button.
  42803. */
  42804. activeButton: number;
  42805. /**
  42806. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  42807. * Higher values reduce its sensitivity.
  42808. */
  42809. angularSensibility: number;
  42810. private _mousemoveCallback;
  42811. private _observer;
  42812. private _rollObserver;
  42813. private previousPosition;
  42814. private noPreventDefault;
  42815. private element;
  42816. /**
  42817. * Listen to mouse events to control the camera.
  42818. * @param touchEnabled Define if touch is enabled. (Default is true.)
  42819. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42820. */
  42821. constructor(touchEnabled?: boolean);
  42822. /**
  42823. * Attach the mouse control to the HTML DOM element.
  42824. * @param element Defines the element that listens to the input events.
  42825. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  42826. */
  42827. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42828. /**
  42829. * Detach the current controls from the specified dom element.
  42830. * @param element Defines the element to stop listening the inputs from
  42831. */
  42832. detachControl(element: Nullable<HTMLElement>): void;
  42833. /**
  42834. * Gets the class name of the current input.
  42835. * @returns the class name.
  42836. */
  42837. getClassName(): string;
  42838. /**
  42839. * Get the friendly name associated with the input class.
  42840. * @returns the input's friendly name.
  42841. */
  42842. getSimpleName(): string;
  42843. private _pointerInput;
  42844. private _onMouseMove;
  42845. /**
  42846. * Rotate camera by mouse offset.
  42847. */
  42848. private rotateCamera;
  42849. }
  42850. }
  42851. declare module BABYLON {
  42852. /**
  42853. * Default Inputs manager for the FlyCamera.
  42854. * It groups all the default supported inputs for ease of use.
  42855. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42856. */
  42857. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  42858. /**
  42859. * Instantiates a new FlyCameraInputsManager.
  42860. * @param camera Defines the camera the inputs belong to.
  42861. */
  42862. constructor(camera: FlyCamera);
  42863. /**
  42864. * Add keyboard input support to the input manager.
  42865. * @returns the new FlyCameraKeyboardMoveInput().
  42866. */
  42867. addKeyboard(): FlyCameraInputsManager;
  42868. /**
  42869. * Add mouse input support to the input manager.
  42870. * @param touchEnabled Enable touch screen support.
  42871. * @returns the new FlyCameraMouseInput().
  42872. */
  42873. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  42874. }
  42875. }
  42876. declare module BABYLON {
  42877. /**
  42878. * This is a flying camera, designed for 3D movement and rotation in all directions,
  42879. * such as in a 3D Space Shooter or a Flight Simulator.
  42880. */
  42881. export class FlyCamera extends TargetCamera {
  42882. /**
  42883. * Define the collision ellipsoid of the camera.
  42884. * This is helpful for simulating a camera body, like a player's body.
  42885. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  42886. */
  42887. ellipsoid: Vector3;
  42888. /**
  42889. * Define an offset for the position of the ellipsoid around the camera.
  42890. * This can be helpful if the camera is attached away from the player's body center,
  42891. * such as at its head.
  42892. */
  42893. ellipsoidOffset: Vector3;
  42894. /**
  42895. * Enable or disable collisions of the camera with the rest of the scene objects.
  42896. */
  42897. checkCollisions: boolean;
  42898. /**
  42899. * Enable or disable gravity on the camera.
  42900. */
  42901. applyGravity: boolean;
  42902. /**
  42903. * Define the current direction the camera is moving to.
  42904. */
  42905. cameraDirection: Vector3;
  42906. /**
  42907. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  42908. * This overrides and empties cameraRotation.
  42909. */
  42910. rotationQuaternion: Quaternion;
  42911. /**
  42912. * Track Roll to maintain the wanted Rolling when looking around.
  42913. */
  42914. _trackRoll: number;
  42915. /**
  42916. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  42917. */
  42918. rollCorrect: number;
  42919. /**
  42920. * Mimic a banked turn, Rolling the camera when Yawing.
  42921. * It's recommended to use rollCorrect = 10 for faster banking correction.
  42922. */
  42923. bankedTurn: boolean;
  42924. /**
  42925. * Limit in radians for how much Roll banking will add. (Default: 90°)
  42926. */
  42927. bankedTurnLimit: number;
  42928. /**
  42929. * Value of 0 disables the banked Roll.
  42930. * Value of 1 is equal to the Yaw angle in radians.
  42931. */
  42932. bankedTurnMultiplier: number;
  42933. /**
  42934. * The inputs manager loads all the input sources, such as keyboard and mouse.
  42935. */
  42936. inputs: FlyCameraInputsManager;
  42937. /**
  42938. * Gets the input sensibility for mouse input.
  42939. * Higher values reduce sensitivity.
  42940. */
  42941. get angularSensibility(): number;
  42942. /**
  42943. * Sets the input sensibility for a mouse input.
  42944. * Higher values reduce sensitivity.
  42945. */
  42946. set angularSensibility(value: number);
  42947. /**
  42948. * Get the keys for camera movement forward.
  42949. */
  42950. get keysForward(): number[];
  42951. /**
  42952. * Set the keys for camera movement forward.
  42953. */
  42954. set keysForward(value: number[]);
  42955. /**
  42956. * Get the keys for camera movement backward.
  42957. */
  42958. get keysBackward(): number[];
  42959. set keysBackward(value: number[]);
  42960. /**
  42961. * Get the keys for camera movement up.
  42962. */
  42963. get keysUp(): number[];
  42964. /**
  42965. * Set the keys for camera movement up.
  42966. */
  42967. set keysUp(value: number[]);
  42968. /**
  42969. * Get the keys for camera movement down.
  42970. */
  42971. get keysDown(): number[];
  42972. /**
  42973. * Set the keys for camera movement down.
  42974. */
  42975. set keysDown(value: number[]);
  42976. /**
  42977. * Get the keys for camera movement left.
  42978. */
  42979. get keysLeft(): number[];
  42980. /**
  42981. * Set the keys for camera movement left.
  42982. */
  42983. set keysLeft(value: number[]);
  42984. /**
  42985. * Set the keys for camera movement right.
  42986. */
  42987. get keysRight(): number[];
  42988. /**
  42989. * Set the keys for camera movement right.
  42990. */
  42991. set keysRight(value: number[]);
  42992. /**
  42993. * Event raised when the camera collides with a mesh in the scene.
  42994. */
  42995. onCollide: (collidedMesh: AbstractMesh) => void;
  42996. private _collider;
  42997. private _needMoveForGravity;
  42998. private _oldPosition;
  42999. private _diffPosition;
  43000. private _newPosition;
  43001. /** @hidden */
  43002. _localDirection: Vector3;
  43003. /** @hidden */
  43004. _transformedDirection: Vector3;
  43005. /**
  43006. * Instantiates a FlyCamera.
  43007. * This is a flying camera, designed for 3D movement and rotation in all directions,
  43008. * such as in a 3D Space Shooter or a Flight Simulator.
  43009. * @param name Define the name of the camera in the scene.
  43010. * @param position Define the starting position of the camera in the scene.
  43011. * @param scene Define the scene the camera belongs to.
  43012. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  43013. */
  43014. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43015. /**
  43016. * Attach a control to the HTML DOM element.
  43017. * @param element Defines the element that listens to the input events.
  43018. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  43019. */
  43020. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43021. /**
  43022. * Detach a control from the HTML DOM element.
  43023. * The camera will stop reacting to that input.
  43024. * @param element Defines the element that listens to the input events.
  43025. */
  43026. detachControl(element: HTMLElement): void;
  43027. private _collisionMask;
  43028. /**
  43029. * Get the mask that the camera ignores in collision events.
  43030. */
  43031. get collisionMask(): number;
  43032. /**
  43033. * Set the mask that the camera ignores in collision events.
  43034. */
  43035. set collisionMask(mask: number);
  43036. /** @hidden */
  43037. _collideWithWorld(displacement: Vector3): void;
  43038. /** @hidden */
  43039. private _onCollisionPositionChange;
  43040. /** @hidden */
  43041. _checkInputs(): void;
  43042. /** @hidden */
  43043. _decideIfNeedsToMove(): boolean;
  43044. /** @hidden */
  43045. _updatePosition(): void;
  43046. /**
  43047. * Restore the Roll to its target value at the rate specified.
  43048. * @param rate - Higher means slower restoring.
  43049. * @hidden
  43050. */
  43051. restoreRoll(rate: number): void;
  43052. /**
  43053. * Destroy the camera and release the current resources held by it.
  43054. */
  43055. dispose(): void;
  43056. /**
  43057. * Get the current object class name.
  43058. * @returns the class name.
  43059. */
  43060. getClassName(): string;
  43061. }
  43062. }
  43063. declare module BABYLON {
  43064. /**
  43065. * Listen to keyboard events to control the camera.
  43066. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43067. */
  43068. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  43069. /**
  43070. * Defines the camera the input is attached to.
  43071. */
  43072. camera: FlyCamera;
  43073. /**
  43074. * The list of keyboard keys used to control the forward move of the camera.
  43075. */
  43076. keysForward: number[];
  43077. /**
  43078. * The list of keyboard keys used to control the backward move of the camera.
  43079. */
  43080. keysBackward: number[];
  43081. /**
  43082. * The list of keyboard keys used to control the forward move of the camera.
  43083. */
  43084. keysUp: number[];
  43085. /**
  43086. * The list of keyboard keys used to control the backward move of the camera.
  43087. */
  43088. keysDown: number[];
  43089. /**
  43090. * The list of keyboard keys used to control the right strafe move of the camera.
  43091. */
  43092. keysRight: number[];
  43093. /**
  43094. * The list of keyboard keys used to control the left strafe move of the camera.
  43095. */
  43096. keysLeft: number[];
  43097. private _keys;
  43098. private _onCanvasBlurObserver;
  43099. private _onKeyboardObserver;
  43100. private _engine;
  43101. private _scene;
  43102. /**
  43103. * Attach the input controls to a specific dom element to get the input from.
  43104. * @param element Defines the element the controls should be listened from
  43105. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43106. */
  43107. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43108. /**
  43109. * Detach the current controls from the specified dom element.
  43110. * @param element Defines the element to stop listening the inputs from
  43111. */
  43112. detachControl(element: Nullable<HTMLElement>): void;
  43113. /**
  43114. * Gets the class name of the current intput.
  43115. * @returns the class name
  43116. */
  43117. getClassName(): string;
  43118. /** @hidden */
  43119. _onLostFocus(e: FocusEvent): void;
  43120. /**
  43121. * Get the friendly name associated with the input class.
  43122. * @returns the input friendly name
  43123. */
  43124. getSimpleName(): string;
  43125. /**
  43126. * Update the current camera state depending on the inputs that have been used this frame.
  43127. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43128. */
  43129. checkInputs(): void;
  43130. }
  43131. }
  43132. declare module BABYLON {
  43133. /**
  43134. * Manage the mouse wheel inputs to control a follow camera.
  43135. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43136. */
  43137. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  43138. /**
  43139. * Defines the camera the input is attached to.
  43140. */
  43141. camera: FollowCamera;
  43142. /**
  43143. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  43144. */
  43145. axisControlRadius: boolean;
  43146. /**
  43147. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  43148. */
  43149. axisControlHeight: boolean;
  43150. /**
  43151. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  43152. */
  43153. axisControlRotation: boolean;
  43154. /**
  43155. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  43156. * relation to mouseWheel events.
  43157. */
  43158. wheelPrecision: number;
  43159. /**
  43160. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  43161. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  43162. */
  43163. wheelDeltaPercentage: number;
  43164. private _wheel;
  43165. private _observer;
  43166. /**
  43167. * Attach the input controls to a specific dom element to get the input from.
  43168. * @param element Defines the element the controls should be listened from
  43169. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43170. */
  43171. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43172. /**
  43173. * Detach the current controls from the specified dom element.
  43174. * @param element Defines the element to stop listening the inputs from
  43175. */
  43176. detachControl(element: Nullable<HTMLElement>): void;
  43177. /**
  43178. * Gets the class name of the current intput.
  43179. * @returns the class name
  43180. */
  43181. getClassName(): string;
  43182. /**
  43183. * Get the friendly name associated with the input class.
  43184. * @returns the input friendly name
  43185. */
  43186. getSimpleName(): string;
  43187. }
  43188. }
  43189. declare module BABYLON {
  43190. /**
  43191. * Manage the pointers inputs to control an follow camera.
  43192. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43193. */
  43194. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  43195. /**
  43196. * Defines the camera the input is attached to.
  43197. */
  43198. camera: FollowCamera;
  43199. /**
  43200. * Gets the class name of the current input.
  43201. * @returns the class name
  43202. */
  43203. getClassName(): string;
  43204. /**
  43205. * Defines the pointer angular sensibility along the X axis or how fast is
  43206. * the camera rotating.
  43207. * A negative number will reverse the axis direction.
  43208. */
  43209. angularSensibilityX: number;
  43210. /**
  43211. * Defines the pointer angular sensibility along the Y axis or how fast is
  43212. * the camera rotating.
  43213. * A negative number will reverse the axis direction.
  43214. */
  43215. angularSensibilityY: number;
  43216. /**
  43217. * Defines the pointer pinch precision or how fast is the camera zooming.
  43218. * A negative number will reverse the axis direction.
  43219. */
  43220. pinchPrecision: number;
  43221. /**
  43222. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  43223. * from 0.
  43224. * It defines the percentage of current camera.radius to use as delta when
  43225. * pinch zoom is used.
  43226. */
  43227. pinchDeltaPercentage: number;
  43228. /**
  43229. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  43230. */
  43231. axisXControlRadius: boolean;
  43232. /**
  43233. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  43234. */
  43235. axisXControlHeight: boolean;
  43236. /**
  43237. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  43238. */
  43239. axisXControlRotation: boolean;
  43240. /**
  43241. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  43242. */
  43243. axisYControlRadius: boolean;
  43244. /**
  43245. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  43246. */
  43247. axisYControlHeight: boolean;
  43248. /**
  43249. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  43250. */
  43251. axisYControlRotation: boolean;
  43252. /**
  43253. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  43254. */
  43255. axisPinchControlRadius: boolean;
  43256. /**
  43257. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  43258. */
  43259. axisPinchControlHeight: boolean;
  43260. /**
  43261. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  43262. */
  43263. axisPinchControlRotation: boolean;
  43264. /**
  43265. * Log error messages if basic misconfiguration has occurred.
  43266. */
  43267. warningEnable: boolean;
  43268. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43269. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43270. private _warningCounter;
  43271. private _warning;
  43272. }
  43273. }
  43274. declare module BABYLON {
  43275. /**
  43276. * Default Inputs manager for the FollowCamera.
  43277. * It groups all the default supported inputs for ease of use.
  43278. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43279. */
  43280. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  43281. /**
  43282. * Instantiates a new FollowCameraInputsManager.
  43283. * @param camera Defines the camera the inputs belong to
  43284. */
  43285. constructor(camera: FollowCamera);
  43286. /**
  43287. * Add keyboard input support to the input manager.
  43288. * @returns the current input manager
  43289. */
  43290. addKeyboard(): FollowCameraInputsManager;
  43291. /**
  43292. * Add mouse wheel input support to the input manager.
  43293. * @returns the current input manager
  43294. */
  43295. addMouseWheel(): FollowCameraInputsManager;
  43296. /**
  43297. * Add pointers input support to the input manager.
  43298. * @returns the current input manager
  43299. */
  43300. addPointers(): FollowCameraInputsManager;
  43301. /**
  43302. * Add orientation input support to the input manager.
  43303. * @returns the current input manager
  43304. */
  43305. addVRDeviceOrientation(): FollowCameraInputsManager;
  43306. }
  43307. }
  43308. declare module BABYLON {
  43309. /**
  43310. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  43311. * an arc rotate version arcFollowCamera are available.
  43312. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43313. */
  43314. export class FollowCamera extends TargetCamera {
  43315. /**
  43316. * Distance the follow camera should follow an object at
  43317. */
  43318. radius: number;
  43319. /**
  43320. * Minimum allowed distance of the camera to the axis of rotation
  43321. * (The camera can not get closer).
  43322. * This can help limiting how the Camera is able to move in the scene.
  43323. */
  43324. lowerRadiusLimit: Nullable<number>;
  43325. /**
  43326. * Maximum allowed distance of the camera to the axis of rotation
  43327. * (The camera can not get further).
  43328. * This can help limiting how the Camera is able to move in the scene.
  43329. */
  43330. upperRadiusLimit: Nullable<number>;
  43331. /**
  43332. * Define a rotation offset between the camera and the object it follows
  43333. */
  43334. rotationOffset: number;
  43335. /**
  43336. * Minimum allowed angle to camera position relative to target object.
  43337. * This can help limiting how the Camera is able to move in the scene.
  43338. */
  43339. lowerRotationOffsetLimit: Nullable<number>;
  43340. /**
  43341. * Maximum allowed angle to camera position relative to target object.
  43342. * This can help limiting how the Camera is able to move in the scene.
  43343. */
  43344. upperRotationOffsetLimit: Nullable<number>;
  43345. /**
  43346. * Define a height offset between the camera and the object it follows.
  43347. * It can help following an object from the top (like a car chaing a plane)
  43348. */
  43349. heightOffset: number;
  43350. /**
  43351. * Minimum allowed height of camera position relative to target object.
  43352. * This can help limiting how the Camera is able to move in the scene.
  43353. */
  43354. lowerHeightOffsetLimit: Nullable<number>;
  43355. /**
  43356. * Maximum allowed height of camera position relative to target object.
  43357. * This can help limiting how the Camera is able to move in the scene.
  43358. */
  43359. upperHeightOffsetLimit: Nullable<number>;
  43360. /**
  43361. * Define how fast the camera can accelerate to follow it s target.
  43362. */
  43363. cameraAcceleration: number;
  43364. /**
  43365. * Define the speed limit of the camera following an object.
  43366. */
  43367. maxCameraSpeed: number;
  43368. /**
  43369. * Define the target of the camera.
  43370. */
  43371. lockedTarget: Nullable<AbstractMesh>;
  43372. /**
  43373. * Defines the input associated with the camera.
  43374. */
  43375. inputs: FollowCameraInputsManager;
  43376. /**
  43377. * Instantiates the follow camera.
  43378. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43379. * @param name Define the name of the camera in the scene
  43380. * @param position Define the position of the camera
  43381. * @param scene Define the scene the camera belong to
  43382. * @param lockedTarget Define the target of the camera
  43383. */
  43384. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  43385. private _follow;
  43386. /**
  43387. * Attached controls to the current camera.
  43388. * @param element Defines the element the controls should be listened from
  43389. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43390. */
  43391. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43392. /**
  43393. * Detach the current controls from the camera.
  43394. * The camera will stop reacting to inputs.
  43395. * @param element Defines the element to stop listening the inputs from
  43396. */
  43397. detachControl(element: HTMLElement): void;
  43398. /** @hidden */
  43399. _checkInputs(): void;
  43400. private _checkLimits;
  43401. /**
  43402. * Gets the camera class name.
  43403. * @returns the class name
  43404. */
  43405. getClassName(): string;
  43406. }
  43407. /**
  43408. * Arc Rotate version of the follow camera.
  43409. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  43410. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43411. */
  43412. export class ArcFollowCamera extends TargetCamera {
  43413. /** The longitudinal angle of the camera */
  43414. alpha: number;
  43415. /** The latitudinal angle of the camera */
  43416. beta: number;
  43417. /** The radius of the camera from its target */
  43418. radius: number;
  43419. /** Define the camera target (the messh it should follow) */
  43420. target: Nullable<AbstractMesh>;
  43421. private _cartesianCoordinates;
  43422. /**
  43423. * Instantiates a new ArcFollowCamera
  43424. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43425. * @param name Define the name of the camera
  43426. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  43427. * @param beta Define the rotation angle of the camera around the elevation axis
  43428. * @param radius Define the radius of the camera from its target point
  43429. * @param target Define the target of the camera
  43430. * @param scene Define the scene the camera belongs to
  43431. */
  43432. constructor(name: string,
  43433. /** The longitudinal angle of the camera */
  43434. alpha: number,
  43435. /** The latitudinal angle of the camera */
  43436. beta: number,
  43437. /** The radius of the camera from its target */
  43438. radius: number,
  43439. /** Define the camera target (the messh it should follow) */
  43440. target: Nullable<AbstractMesh>, scene: Scene);
  43441. private _follow;
  43442. /** @hidden */
  43443. _checkInputs(): void;
  43444. /**
  43445. * Returns the class name of the object.
  43446. * It is mostly used internally for serialization purposes.
  43447. */
  43448. getClassName(): string;
  43449. }
  43450. }
  43451. declare module BABYLON {
  43452. /**
  43453. * Manage the keyboard inputs to control the movement of a follow camera.
  43454. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43455. */
  43456. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  43457. /**
  43458. * Defines the camera the input is attached to.
  43459. */
  43460. camera: FollowCamera;
  43461. /**
  43462. * Defines the list of key codes associated with the up action (increase heightOffset)
  43463. */
  43464. keysHeightOffsetIncr: number[];
  43465. /**
  43466. * Defines the list of key codes associated with the down action (decrease heightOffset)
  43467. */
  43468. keysHeightOffsetDecr: number[];
  43469. /**
  43470. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  43471. */
  43472. keysHeightOffsetModifierAlt: boolean;
  43473. /**
  43474. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  43475. */
  43476. keysHeightOffsetModifierCtrl: boolean;
  43477. /**
  43478. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  43479. */
  43480. keysHeightOffsetModifierShift: boolean;
  43481. /**
  43482. * Defines the list of key codes associated with the left action (increase rotationOffset)
  43483. */
  43484. keysRotationOffsetIncr: number[];
  43485. /**
  43486. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  43487. */
  43488. keysRotationOffsetDecr: number[];
  43489. /**
  43490. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  43491. */
  43492. keysRotationOffsetModifierAlt: boolean;
  43493. /**
  43494. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  43495. */
  43496. keysRotationOffsetModifierCtrl: boolean;
  43497. /**
  43498. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  43499. */
  43500. keysRotationOffsetModifierShift: boolean;
  43501. /**
  43502. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  43503. */
  43504. keysRadiusIncr: number[];
  43505. /**
  43506. * Defines the list of key codes associated with the zoom-out action (increase radius)
  43507. */
  43508. keysRadiusDecr: number[];
  43509. /**
  43510. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  43511. */
  43512. keysRadiusModifierAlt: boolean;
  43513. /**
  43514. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  43515. */
  43516. keysRadiusModifierCtrl: boolean;
  43517. /**
  43518. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  43519. */
  43520. keysRadiusModifierShift: boolean;
  43521. /**
  43522. * Defines the rate of change of heightOffset.
  43523. */
  43524. heightSensibility: number;
  43525. /**
  43526. * Defines the rate of change of rotationOffset.
  43527. */
  43528. rotationSensibility: number;
  43529. /**
  43530. * Defines the rate of change of radius.
  43531. */
  43532. radiusSensibility: number;
  43533. private _keys;
  43534. private _ctrlPressed;
  43535. private _altPressed;
  43536. private _shiftPressed;
  43537. private _onCanvasBlurObserver;
  43538. private _onKeyboardObserver;
  43539. private _engine;
  43540. private _scene;
  43541. /**
  43542. * Attach the input controls to a specific dom element to get the input from.
  43543. * @param element Defines the element the controls should be listened from
  43544. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43545. */
  43546. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43547. /**
  43548. * Detach the current controls from the specified dom element.
  43549. * @param element Defines the element to stop listening the inputs from
  43550. */
  43551. detachControl(element: Nullable<HTMLElement>): void;
  43552. /**
  43553. * Update the current camera state depending on the inputs that have been used this frame.
  43554. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43555. */
  43556. checkInputs(): void;
  43557. /**
  43558. * Gets the class name of the current input.
  43559. * @returns the class name
  43560. */
  43561. getClassName(): string;
  43562. /**
  43563. * Get the friendly name associated with the input class.
  43564. * @returns the input friendly name
  43565. */
  43566. getSimpleName(): string;
  43567. /**
  43568. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43569. * allow modification of the heightOffset value.
  43570. */
  43571. private _modifierHeightOffset;
  43572. /**
  43573. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43574. * allow modification of the rotationOffset value.
  43575. */
  43576. private _modifierRotationOffset;
  43577. /**
  43578. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43579. * allow modification of the radius value.
  43580. */
  43581. private _modifierRadius;
  43582. }
  43583. }
  43584. declare module BABYLON {
  43585. interface FreeCameraInputsManager {
  43586. /**
  43587. * @hidden
  43588. */
  43589. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  43590. /**
  43591. * Add orientation input support to the input manager.
  43592. * @returns the current input manager
  43593. */
  43594. addDeviceOrientation(): FreeCameraInputsManager;
  43595. }
  43596. /**
  43597. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  43598. * Screen rotation is taken into account.
  43599. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43600. */
  43601. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  43602. private _camera;
  43603. private _screenOrientationAngle;
  43604. private _constantTranform;
  43605. private _screenQuaternion;
  43606. private _alpha;
  43607. private _beta;
  43608. private _gamma;
  43609. /**
  43610. * Can be used to detect if a device orientation sensor is available on a device
  43611. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  43612. * @returns a promise that will resolve on orientation change
  43613. */
  43614. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  43615. /**
  43616. * @hidden
  43617. */
  43618. _onDeviceOrientationChangedObservable: Observable<void>;
  43619. /**
  43620. * Instantiates a new input
  43621. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43622. */
  43623. constructor();
  43624. /**
  43625. * Define the camera controlled by the input.
  43626. */
  43627. get camera(): FreeCamera;
  43628. set camera(camera: FreeCamera);
  43629. /**
  43630. * Attach the input controls to a specific dom element to get the input from.
  43631. * @param element Defines the element the controls should be listened from
  43632. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43633. */
  43634. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43635. private _orientationChanged;
  43636. private _deviceOrientation;
  43637. /**
  43638. * Detach the current controls from the specified dom element.
  43639. * @param element Defines the element to stop listening the inputs from
  43640. */
  43641. detachControl(element: Nullable<HTMLElement>): void;
  43642. /**
  43643. * Update the current camera state depending on the inputs that have been used this frame.
  43644. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43645. */
  43646. checkInputs(): void;
  43647. /**
  43648. * Gets the class name of the current intput.
  43649. * @returns the class name
  43650. */
  43651. getClassName(): string;
  43652. /**
  43653. * Get the friendly name associated with the input class.
  43654. * @returns the input friendly name
  43655. */
  43656. getSimpleName(): string;
  43657. }
  43658. }
  43659. declare module BABYLON {
  43660. /**
  43661. * Manage the gamepad inputs to control a free camera.
  43662. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43663. */
  43664. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  43665. /**
  43666. * Define the camera the input is attached to.
  43667. */
  43668. camera: FreeCamera;
  43669. /**
  43670. * Define the Gamepad controlling the input
  43671. */
  43672. gamepad: Nullable<Gamepad>;
  43673. /**
  43674. * Defines the gamepad rotation sensiblity.
  43675. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43676. */
  43677. gamepadAngularSensibility: number;
  43678. /**
  43679. * Defines the gamepad move sensiblity.
  43680. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43681. */
  43682. gamepadMoveSensibility: number;
  43683. private _yAxisScale;
  43684. /**
  43685. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  43686. */
  43687. get invertYAxis(): boolean;
  43688. set invertYAxis(value: boolean);
  43689. private _onGamepadConnectedObserver;
  43690. private _onGamepadDisconnectedObserver;
  43691. private _cameraTransform;
  43692. private _deltaTransform;
  43693. private _vector3;
  43694. private _vector2;
  43695. /**
  43696. * Attach the input controls to a specific dom element to get the input from.
  43697. * @param element Defines the element the controls should be listened from
  43698. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43699. */
  43700. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43701. /**
  43702. * Detach the current controls from the specified dom element.
  43703. * @param element Defines the element to stop listening the inputs from
  43704. */
  43705. detachControl(element: Nullable<HTMLElement>): void;
  43706. /**
  43707. * Update the current camera state depending on the inputs that have been used this frame.
  43708. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43709. */
  43710. checkInputs(): void;
  43711. /**
  43712. * Gets the class name of the current intput.
  43713. * @returns the class name
  43714. */
  43715. getClassName(): string;
  43716. /**
  43717. * Get the friendly name associated with the input class.
  43718. * @returns the input friendly name
  43719. */
  43720. getSimpleName(): string;
  43721. }
  43722. }
  43723. declare module BABYLON {
  43724. /**
  43725. * Defines the potential axis of a Joystick
  43726. */
  43727. export enum JoystickAxis {
  43728. /** X axis */
  43729. X = 0,
  43730. /** Y axis */
  43731. Y = 1,
  43732. /** Z axis */
  43733. Z = 2
  43734. }
  43735. /**
  43736. * Class used to define virtual joystick (used in touch mode)
  43737. */
  43738. export class VirtualJoystick {
  43739. /**
  43740. * Gets or sets a boolean indicating that left and right values must be inverted
  43741. */
  43742. reverseLeftRight: boolean;
  43743. /**
  43744. * Gets or sets a boolean indicating that up and down values must be inverted
  43745. */
  43746. reverseUpDown: boolean;
  43747. /**
  43748. * Gets the offset value for the position (ie. the change of the position value)
  43749. */
  43750. deltaPosition: Vector3;
  43751. /**
  43752. * Gets a boolean indicating if the virtual joystick was pressed
  43753. */
  43754. pressed: boolean;
  43755. /**
  43756. * Canvas the virtual joystick will render onto, default z-index of this is 5
  43757. */
  43758. static Canvas: Nullable<HTMLCanvasElement>;
  43759. private static _globalJoystickIndex;
  43760. private static vjCanvasContext;
  43761. private static vjCanvasWidth;
  43762. private static vjCanvasHeight;
  43763. private static halfWidth;
  43764. private _action;
  43765. private _axisTargetedByLeftAndRight;
  43766. private _axisTargetedByUpAndDown;
  43767. private _joystickSensibility;
  43768. private _inversedSensibility;
  43769. private _joystickPointerID;
  43770. private _joystickColor;
  43771. private _joystickPointerPos;
  43772. private _joystickPreviousPointerPos;
  43773. private _joystickPointerStartPos;
  43774. private _deltaJoystickVector;
  43775. private _leftJoystick;
  43776. private _touches;
  43777. private _onPointerDownHandlerRef;
  43778. private _onPointerMoveHandlerRef;
  43779. private _onPointerUpHandlerRef;
  43780. private _onResize;
  43781. /**
  43782. * Creates a new virtual joystick
  43783. * @param leftJoystick defines that the joystick is for left hand (false by default)
  43784. */
  43785. constructor(leftJoystick?: boolean);
  43786. /**
  43787. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  43788. * @param newJoystickSensibility defines the new sensibility
  43789. */
  43790. setJoystickSensibility(newJoystickSensibility: number): void;
  43791. private _onPointerDown;
  43792. private _onPointerMove;
  43793. private _onPointerUp;
  43794. /**
  43795. * Change the color of the virtual joystick
  43796. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  43797. */
  43798. setJoystickColor(newColor: string): void;
  43799. /**
  43800. * Defines a callback to call when the joystick is touched
  43801. * @param action defines the callback
  43802. */
  43803. setActionOnTouch(action: () => any): void;
  43804. /**
  43805. * Defines which axis you'd like to control for left & right
  43806. * @param axis defines the axis to use
  43807. */
  43808. setAxisForLeftRight(axis: JoystickAxis): void;
  43809. /**
  43810. * Defines which axis you'd like to control for up & down
  43811. * @param axis defines the axis to use
  43812. */
  43813. setAxisForUpDown(axis: JoystickAxis): void;
  43814. private _drawVirtualJoystick;
  43815. /**
  43816. * Release internal HTML canvas
  43817. */
  43818. releaseCanvas(): void;
  43819. }
  43820. }
  43821. declare module BABYLON {
  43822. interface FreeCameraInputsManager {
  43823. /**
  43824. * Add virtual joystick input support to the input manager.
  43825. * @returns the current input manager
  43826. */
  43827. addVirtualJoystick(): FreeCameraInputsManager;
  43828. }
  43829. /**
  43830. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  43831. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43832. */
  43833. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  43834. /**
  43835. * Defines the camera the input is attached to.
  43836. */
  43837. camera: FreeCamera;
  43838. private _leftjoystick;
  43839. private _rightjoystick;
  43840. /**
  43841. * Gets the left stick of the virtual joystick.
  43842. * @returns The virtual Joystick
  43843. */
  43844. getLeftJoystick(): VirtualJoystick;
  43845. /**
  43846. * Gets the right stick of the virtual joystick.
  43847. * @returns The virtual Joystick
  43848. */
  43849. getRightJoystick(): VirtualJoystick;
  43850. /**
  43851. * Update the current camera state depending on the inputs that have been used this frame.
  43852. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43853. */
  43854. checkInputs(): void;
  43855. /**
  43856. * Attach the input controls to a specific dom element to get the input from.
  43857. * @param element Defines the element the controls should be listened from
  43858. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43859. */
  43860. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43861. /**
  43862. * Detach the current controls from the specified dom element.
  43863. * @param element Defines the element to stop listening the inputs from
  43864. */
  43865. detachControl(element: Nullable<HTMLElement>): void;
  43866. /**
  43867. * Gets the class name of the current intput.
  43868. * @returns the class name
  43869. */
  43870. getClassName(): string;
  43871. /**
  43872. * Get the friendly name associated with the input class.
  43873. * @returns the input friendly name
  43874. */
  43875. getSimpleName(): string;
  43876. }
  43877. }
  43878. declare module BABYLON {
  43879. /**
  43880. * This represents a FPS type of camera controlled by touch.
  43881. * This is like a universal camera minus the Gamepad controls.
  43882. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43883. */
  43884. export class TouchCamera extends FreeCamera {
  43885. /**
  43886. * Defines the touch sensibility for rotation.
  43887. * The higher the faster.
  43888. */
  43889. get touchAngularSensibility(): number;
  43890. set touchAngularSensibility(value: number);
  43891. /**
  43892. * Defines the touch sensibility for move.
  43893. * The higher the faster.
  43894. */
  43895. get touchMoveSensibility(): number;
  43896. set touchMoveSensibility(value: number);
  43897. /**
  43898. * Instantiates a new touch camera.
  43899. * This represents a FPS type of camera controlled by touch.
  43900. * This is like a universal camera minus the Gamepad controls.
  43901. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43902. * @param name Define the name of the camera in the scene
  43903. * @param position Define the start position of the camera in the scene
  43904. * @param scene Define the scene the camera belongs to
  43905. */
  43906. constructor(name: string, position: Vector3, scene: Scene);
  43907. /**
  43908. * Gets the current object class name.
  43909. * @return the class name
  43910. */
  43911. getClassName(): string;
  43912. /** @hidden */
  43913. _setupInputs(): void;
  43914. }
  43915. }
  43916. declare module BABYLON {
  43917. /**
  43918. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  43919. * being tilted forward or back and left or right.
  43920. */
  43921. export class DeviceOrientationCamera extends FreeCamera {
  43922. private _initialQuaternion;
  43923. private _quaternionCache;
  43924. private _tmpDragQuaternion;
  43925. private _disablePointerInputWhenUsingDeviceOrientation;
  43926. /**
  43927. * Creates a new device orientation camera
  43928. * @param name The name of the camera
  43929. * @param position The start position camera
  43930. * @param scene The scene the camera belongs to
  43931. */
  43932. constructor(name: string, position: Vector3, scene: Scene);
  43933. /**
  43934. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  43935. */
  43936. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  43937. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  43938. private _dragFactor;
  43939. /**
  43940. * Enabled turning on the y axis when the orientation sensor is active
  43941. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  43942. */
  43943. enableHorizontalDragging(dragFactor?: number): void;
  43944. /**
  43945. * Gets the current instance class name ("DeviceOrientationCamera").
  43946. * This helps avoiding instanceof at run time.
  43947. * @returns the class name
  43948. */
  43949. getClassName(): string;
  43950. /**
  43951. * @hidden
  43952. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  43953. */
  43954. _checkInputs(): void;
  43955. /**
  43956. * Reset the camera to its default orientation on the specified axis only.
  43957. * @param axis The axis to reset
  43958. */
  43959. resetToCurrentRotation(axis?: Axis): void;
  43960. }
  43961. }
  43962. declare module BABYLON {
  43963. /**
  43964. * Defines supported buttons for XBox360 compatible gamepads
  43965. */
  43966. export enum Xbox360Button {
  43967. /** A */
  43968. A = 0,
  43969. /** B */
  43970. B = 1,
  43971. /** X */
  43972. X = 2,
  43973. /** Y */
  43974. Y = 3,
  43975. /** Left button */
  43976. LB = 4,
  43977. /** Right button */
  43978. RB = 5,
  43979. /** Back */
  43980. Back = 8,
  43981. /** Start */
  43982. Start = 9,
  43983. /** Left stick */
  43984. LeftStick = 10,
  43985. /** Right stick */
  43986. RightStick = 11
  43987. }
  43988. /** Defines values for XBox360 DPad */
  43989. export enum Xbox360Dpad {
  43990. /** Up */
  43991. Up = 12,
  43992. /** Down */
  43993. Down = 13,
  43994. /** Left */
  43995. Left = 14,
  43996. /** Right */
  43997. Right = 15
  43998. }
  43999. /**
  44000. * Defines a XBox360 gamepad
  44001. */
  44002. export class Xbox360Pad extends Gamepad {
  44003. private _leftTrigger;
  44004. private _rightTrigger;
  44005. private _onlefttriggerchanged;
  44006. private _onrighttriggerchanged;
  44007. private _onbuttondown;
  44008. private _onbuttonup;
  44009. private _ondpaddown;
  44010. private _ondpadup;
  44011. /** Observable raised when a button is pressed */
  44012. onButtonDownObservable: Observable<Xbox360Button>;
  44013. /** Observable raised when a button is released */
  44014. onButtonUpObservable: Observable<Xbox360Button>;
  44015. /** Observable raised when a pad is pressed */
  44016. onPadDownObservable: Observable<Xbox360Dpad>;
  44017. /** Observable raised when a pad is released */
  44018. onPadUpObservable: Observable<Xbox360Dpad>;
  44019. private _buttonA;
  44020. private _buttonB;
  44021. private _buttonX;
  44022. private _buttonY;
  44023. private _buttonBack;
  44024. private _buttonStart;
  44025. private _buttonLB;
  44026. private _buttonRB;
  44027. private _buttonLeftStick;
  44028. private _buttonRightStick;
  44029. private _dPadUp;
  44030. private _dPadDown;
  44031. private _dPadLeft;
  44032. private _dPadRight;
  44033. private _isXboxOnePad;
  44034. /**
  44035. * Creates a new XBox360 gamepad object
  44036. * @param id defines the id of this gamepad
  44037. * @param index defines its index
  44038. * @param gamepad defines the internal HTML gamepad object
  44039. * @param xboxOne defines if it is a XBox One gamepad
  44040. */
  44041. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  44042. /**
  44043. * Defines the callback to call when left trigger is pressed
  44044. * @param callback defines the callback to use
  44045. */
  44046. onlefttriggerchanged(callback: (value: number) => void): void;
  44047. /**
  44048. * Defines the callback to call when right trigger is pressed
  44049. * @param callback defines the callback to use
  44050. */
  44051. onrighttriggerchanged(callback: (value: number) => void): void;
  44052. /**
  44053. * Gets the left trigger value
  44054. */
  44055. get leftTrigger(): number;
  44056. /**
  44057. * Sets the left trigger value
  44058. */
  44059. set leftTrigger(newValue: number);
  44060. /**
  44061. * Gets the right trigger value
  44062. */
  44063. get rightTrigger(): number;
  44064. /**
  44065. * Sets the right trigger value
  44066. */
  44067. set rightTrigger(newValue: number);
  44068. /**
  44069. * Defines the callback to call when a button is pressed
  44070. * @param callback defines the callback to use
  44071. */
  44072. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  44073. /**
  44074. * Defines the callback to call when a button is released
  44075. * @param callback defines the callback to use
  44076. */
  44077. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  44078. /**
  44079. * Defines the callback to call when a pad is pressed
  44080. * @param callback defines the callback to use
  44081. */
  44082. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  44083. /**
  44084. * Defines the callback to call when a pad is released
  44085. * @param callback defines the callback to use
  44086. */
  44087. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  44088. private _setButtonValue;
  44089. private _setDPadValue;
  44090. /**
  44091. * Gets the value of the `A` button
  44092. */
  44093. get buttonA(): number;
  44094. /**
  44095. * Sets the value of the `A` button
  44096. */
  44097. set buttonA(value: number);
  44098. /**
  44099. * Gets the value of the `B` button
  44100. */
  44101. get buttonB(): number;
  44102. /**
  44103. * Sets the value of the `B` button
  44104. */
  44105. set buttonB(value: number);
  44106. /**
  44107. * Gets the value of the `X` button
  44108. */
  44109. get buttonX(): number;
  44110. /**
  44111. * Sets the value of the `X` button
  44112. */
  44113. set buttonX(value: number);
  44114. /**
  44115. * Gets the value of the `Y` button
  44116. */
  44117. get buttonY(): number;
  44118. /**
  44119. * Sets the value of the `Y` button
  44120. */
  44121. set buttonY(value: number);
  44122. /**
  44123. * Gets the value of the `Start` button
  44124. */
  44125. get buttonStart(): number;
  44126. /**
  44127. * Sets the value of the `Start` button
  44128. */
  44129. set buttonStart(value: number);
  44130. /**
  44131. * Gets the value of the `Back` button
  44132. */
  44133. get buttonBack(): number;
  44134. /**
  44135. * Sets the value of the `Back` button
  44136. */
  44137. set buttonBack(value: number);
  44138. /**
  44139. * Gets the value of the `Left` button
  44140. */
  44141. get buttonLB(): number;
  44142. /**
  44143. * Sets the value of the `Left` button
  44144. */
  44145. set buttonLB(value: number);
  44146. /**
  44147. * Gets the value of the `Right` button
  44148. */
  44149. get buttonRB(): number;
  44150. /**
  44151. * Sets the value of the `Right` button
  44152. */
  44153. set buttonRB(value: number);
  44154. /**
  44155. * Gets the value of the Left joystick
  44156. */
  44157. get buttonLeftStick(): number;
  44158. /**
  44159. * Sets the value of the Left joystick
  44160. */
  44161. set buttonLeftStick(value: number);
  44162. /**
  44163. * Gets the value of the Right joystick
  44164. */
  44165. get buttonRightStick(): number;
  44166. /**
  44167. * Sets the value of the Right joystick
  44168. */
  44169. set buttonRightStick(value: number);
  44170. /**
  44171. * Gets the value of D-pad up
  44172. */
  44173. get dPadUp(): number;
  44174. /**
  44175. * Sets the value of D-pad up
  44176. */
  44177. set dPadUp(value: number);
  44178. /**
  44179. * Gets the value of D-pad down
  44180. */
  44181. get dPadDown(): number;
  44182. /**
  44183. * Sets the value of D-pad down
  44184. */
  44185. set dPadDown(value: number);
  44186. /**
  44187. * Gets the value of D-pad left
  44188. */
  44189. get dPadLeft(): number;
  44190. /**
  44191. * Sets the value of D-pad left
  44192. */
  44193. set dPadLeft(value: number);
  44194. /**
  44195. * Gets the value of D-pad right
  44196. */
  44197. get dPadRight(): number;
  44198. /**
  44199. * Sets the value of D-pad right
  44200. */
  44201. set dPadRight(value: number);
  44202. /**
  44203. * Force the gamepad to synchronize with device values
  44204. */
  44205. update(): void;
  44206. /**
  44207. * Disposes the gamepad
  44208. */
  44209. dispose(): void;
  44210. }
  44211. }
  44212. declare module BABYLON {
  44213. /**
  44214. * Defines supported buttons for DualShock compatible gamepads
  44215. */
  44216. export enum DualShockButton {
  44217. /** Cross */
  44218. Cross = 0,
  44219. /** Circle */
  44220. Circle = 1,
  44221. /** Square */
  44222. Square = 2,
  44223. /** Triangle */
  44224. Triangle = 3,
  44225. /** L1 */
  44226. L1 = 4,
  44227. /** R1 */
  44228. R1 = 5,
  44229. /** Share */
  44230. Share = 8,
  44231. /** Options */
  44232. Options = 9,
  44233. /** Left stick */
  44234. LeftStick = 10,
  44235. /** Right stick */
  44236. RightStick = 11
  44237. }
  44238. /** Defines values for DualShock DPad */
  44239. export enum DualShockDpad {
  44240. /** Up */
  44241. Up = 12,
  44242. /** Down */
  44243. Down = 13,
  44244. /** Left */
  44245. Left = 14,
  44246. /** Right */
  44247. Right = 15
  44248. }
  44249. /**
  44250. * Defines a DualShock gamepad
  44251. */
  44252. export class DualShockPad extends Gamepad {
  44253. private _leftTrigger;
  44254. private _rightTrigger;
  44255. private _onlefttriggerchanged;
  44256. private _onrighttriggerchanged;
  44257. private _onbuttondown;
  44258. private _onbuttonup;
  44259. private _ondpaddown;
  44260. private _ondpadup;
  44261. /** Observable raised when a button is pressed */
  44262. onButtonDownObservable: Observable<DualShockButton>;
  44263. /** Observable raised when a button is released */
  44264. onButtonUpObservable: Observable<DualShockButton>;
  44265. /** Observable raised when a pad is pressed */
  44266. onPadDownObservable: Observable<DualShockDpad>;
  44267. /** Observable raised when a pad is released */
  44268. onPadUpObservable: Observable<DualShockDpad>;
  44269. private _buttonCross;
  44270. private _buttonCircle;
  44271. private _buttonSquare;
  44272. private _buttonTriangle;
  44273. private _buttonShare;
  44274. private _buttonOptions;
  44275. private _buttonL1;
  44276. private _buttonR1;
  44277. private _buttonLeftStick;
  44278. private _buttonRightStick;
  44279. private _dPadUp;
  44280. private _dPadDown;
  44281. private _dPadLeft;
  44282. private _dPadRight;
  44283. /**
  44284. * Creates a new DualShock gamepad object
  44285. * @param id defines the id of this gamepad
  44286. * @param index defines its index
  44287. * @param gamepad defines the internal HTML gamepad object
  44288. */
  44289. constructor(id: string, index: number, gamepad: any);
  44290. /**
  44291. * Defines the callback to call when left trigger is pressed
  44292. * @param callback defines the callback to use
  44293. */
  44294. onlefttriggerchanged(callback: (value: number) => void): void;
  44295. /**
  44296. * Defines the callback to call when right trigger is pressed
  44297. * @param callback defines the callback to use
  44298. */
  44299. onrighttriggerchanged(callback: (value: number) => void): void;
  44300. /**
  44301. * Gets the left trigger value
  44302. */
  44303. get leftTrigger(): number;
  44304. /**
  44305. * Sets the left trigger value
  44306. */
  44307. set leftTrigger(newValue: number);
  44308. /**
  44309. * Gets the right trigger value
  44310. */
  44311. get rightTrigger(): number;
  44312. /**
  44313. * Sets the right trigger value
  44314. */
  44315. set rightTrigger(newValue: number);
  44316. /**
  44317. * Defines the callback to call when a button is pressed
  44318. * @param callback defines the callback to use
  44319. */
  44320. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  44321. /**
  44322. * Defines the callback to call when a button is released
  44323. * @param callback defines the callback to use
  44324. */
  44325. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  44326. /**
  44327. * Defines the callback to call when a pad is pressed
  44328. * @param callback defines the callback to use
  44329. */
  44330. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  44331. /**
  44332. * Defines the callback to call when a pad is released
  44333. * @param callback defines the callback to use
  44334. */
  44335. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  44336. private _setButtonValue;
  44337. private _setDPadValue;
  44338. /**
  44339. * Gets the value of the `Cross` button
  44340. */
  44341. get buttonCross(): number;
  44342. /**
  44343. * Sets the value of the `Cross` button
  44344. */
  44345. set buttonCross(value: number);
  44346. /**
  44347. * Gets the value of the `Circle` button
  44348. */
  44349. get buttonCircle(): number;
  44350. /**
  44351. * Sets the value of the `Circle` button
  44352. */
  44353. set buttonCircle(value: number);
  44354. /**
  44355. * Gets the value of the `Square` button
  44356. */
  44357. get buttonSquare(): number;
  44358. /**
  44359. * Sets the value of the `Square` button
  44360. */
  44361. set buttonSquare(value: number);
  44362. /**
  44363. * Gets the value of the `Triangle` button
  44364. */
  44365. get buttonTriangle(): number;
  44366. /**
  44367. * Sets the value of the `Triangle` button
  44368. */
  44369. set buttonTriangle(value: number);
  44370. /**
  44371. * Gets the value of the `Options` button
  44372. */
  44373. get buttonOptions(): number;
  44374. /**
  44375. * Sets the value of the `Options` button
  44376. */
  44377. set buttonOptions(value: number);
  44378. /**
  44379. * Gets the value of the `Share` button
  44380. */
  44381. get buttonShare(): number;
  44382. /**
  44383. * Sets the value of the `Share` button
  44384. */
  44385. set buttonShare(value: number);
  44386. /**
  44387. * Gets the value of the `L1` button
  44388. */
  44389. get buttonL1(): number;
  44390. /**
  44391. * Sets the value of the `L1` button
  44392. */
  44393. set buttonL1(value: number);
  44394. /**
  44395. * Gets the value of the `R1` button
  44396. */
  44397. get buttonR1(): number;
  44398. /**
  44399. * Sets the value of the `R1` button
  44400. */
  44401. set buttonR1(value: number);
  44402. /**
  44403. * Gets the value of the Left joystick
  44404. */
  44405. get buttonLeftStick(): number;
  44406. /**
  44407. * Sets the value of the Left joystick
  44408. */
  44409. set buttonLeftStick(value: number);
  44410. /**
  44411. * Gets the value of the Right joystick
  44412. */
  44413. get buttonRightStick(): number;
  44414. /**
  44415. * Sets the value of the Right joystick
  44416. */
  44417. set buttonRightStick(value: number);
  44418. /**
  44419. * Gets the value of D-pad up
  44420. */
  44421. get dPadUp(): number;
  44422. /**
  44423. * Sets the value of D-pad up
  44424. */
  44425. set dPadUp(value: number);
  44426. /**
  44427. * Gets the value of D-pad down
  44428. */
  44429. get dPadDown(): number;
  44430. /**
  44431. * Sets the value of D-pad down
  44432. */
  44433. set dPadDown(value: number);
  44434. /**
  44435. * Gets the value of D-pad left
  44436. */
  44437. get dPadLeft(): number;
  44438. /**
  44439. * Sets the value of D-pad left
  44440. */
  44441. set dPadLeft(value: number);
  44442. /**
  44443. * Gets the value of D-pad right
  44444. */
  44445. get dPadRight(): number;
  44446. /**
  44447. * Sets the value of D-pad right
  44448. */
  44449. set dPadRight(value: number);
  44450. /**
  44451. * Force the gamepad to synchronize with device values
  44452. */
  44453. update(): void;
  44454. /**
  44455. * Disposes the gamepad
  44456. */
  44457. dispose(): void;
  44458. }
  44459. }
  44460. declare module BABYLON {
  44461. /**
  44462. * Manager for handling gamepads
  44463. */
  44464. export class GamepadManager {
  44465. private _scene?;
  44466. private _babylonGamepads;
  44467. private _oneGamepadConnected;
  44468. /** @hidden */
  44469. _isMonitoring: boolean;
  44470. private _gamepadEventSupported;
  44471. private _gamepadSupport?;
  44472. /**
  44473. * observable to be triggered when the gamepad controller has been connected
  44474. */
  44475. onGamepadConnectedObservable: Observable<Gamepad>;
  44476. /**
  44477. * observable to be triggered when the gamepad controller has been disconnected
  44478. */
  44479. onGamepadDisconnectedObservable: Observable<Gamepad>;
  44480. private _onGamepadConnectedEvent;
  44481. private _onGamepadDisconnectedEvent;
  44482. /**
  44483. * Initializes the gamepad manager
  44484. * @param _scene BabylonJS scene
  44485. */
  44486. constructor(_scene?: Scene | undefined);
  44487. /**
  44488. * The gamepads in the game pad manager
  44489. */
  44490. get gamepads(): Gamepad[];
  44491. /**
  44492. * Get the gamepad controllers based on type
  44493. * @param type The type of gamepad controller
  44494. * @returns Nullable gamepad
  44495. */
  44496. getGamepadByType(type?: number): Nullable<Gamepad>;
  44497. /**
  44498. * Disposes the gamepad manager
  44499. */
  44500. dispose(): void;
  44501. private _addNewGamepad;
  44502. private _startMonitoringGamepads;
  44503. private _stopMonitoringGamepads;
  44504. /** @hidden */
  44505. _checkGamepadsStatus(): void;
  44506. private _updateGamepadObjects;
  44507. }
  44508. }
  44509. declare module BABYLON {
  44510. interface Scene {
  44511. /** @hidden */
  44512. _gamepadManager: Nullable<GamepadManager>;
  44513. /**
  44514. * Gets the gamepad manager associated with the scene
  44515. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  44516. */
  44517. gamepadManager: GamepadManager;
  44518. }
  44519. /**
  44520. * Interface representing a free camera inputs manager
  44521. */
  44522. interface FreeCameraInputsManager {
  44523. /**
  44524. * Adds gamepad input support to the FreeCameraInputsManager.
  44525. * @returns the FreeCameraInputsManager
  44526. */
  44527. addGamepad(): FreeCameraInputsManager;
  44528. }
  44529. /**
  44530. * Interface representing an arc rotate camera inputs manager
  44531. */
  44532. interface ArcRotateCameraInputsManager {
  44533. /**
  44534. * Adds gamepad input support to the ArcRotateCamera InputManager.
  44535. * @returns the camera inputs manager
  44536. */
  44537. addGamepad(): ArcRotateCameraInputsManager;
  44538. }
  44539. /**
  44540. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  44541. */
  44542. export class GamepadSystemSceneComponent implements ISceneComponent {
  44543. /**
  44544. * The component name helpfull to identify the component in the list of scene components.
  44545. */
  44546. readonly name: string;
  44547. /**
  44548. * The scene the component belongs to.
  44549. */
  44550. scene: Scene;
  44551. /**
  44552. * Creates a new instance of the component for the given scene
  44553. * @param scene Defines the scene to register the component in
  44554. */
  44555. constructor(scene: Scene);
  44556. /**
  44557. * Registers the component in a given scene
  44558. */
  44559. register(): void;
  44560. /**
  44561. * Rebuilds the elements related to this component in case of
  44562. * context lost for instance.
  44563. */
  44564. rebuild(): void;
  44565. /**
  44566. * Disposes the component and the associated ressources
  44567. */
  44568. dispose(): void;
  44569. private _beforeCameraUpdate;
  44570. }
  44571. }
  44572. declare module BABYLON {
  44573. /**
  44574. * 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,
  44575. * which still works and will still be found in many Playgrounds.
  44576. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44577. */
  44578. export class UniversalCamera extends TouchCamera {
  44579. /**
  44580. * Defines the gamepad rotation sensiblity.
  44581. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44582. */
  44583. get gamepadAngularSensibility(): number;
  44584. set gamepadAngularSensibility(value: number);
  44585. /**
  44586. * Defines the gamepad move sensiblity.
  44587. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44588. */
  44589. get gamepadMoveSensibility(): number;
  44590. set gamepadMoveSensibility(value: number);
  44591. /**
  44592. * 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,
  44593. * which still works and will still be found in many Playgrounds.
  44594. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44595. * @param name Define the name of the camera in the scene
  44596. * @param position Define the start position of the camera in the scene
  44597. * @param scene Define the scene the camera belongs to
  44598. */
  44599. constructor(name: string, position: Vector3, scene: Scene);
  44600. /**
  44601. * Gets the current object class name.
  44602. * @return the class name
  44603. */
  44604. getClassName(): string;
  44605. }
  44606. }
  44607. declare module BABYLON {
  44608. /**
  44609. * This represents a FPS type of camera. This is only here for back compat purpose.
  44610. * Please use the UniversalCamera instead as both are identical.
  44611. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44612. */
  44613. export class GamepadCamera extends UniversalCamera {
  44614. /**
  44615. * Instantiates a new Gamepad Camera
  44616. * This represents a FPS type of camera. This is only here for back compat purpose.
  44617. * Please use the UniversalCamera instead as both are identical.
  44618. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44619. * @param name Define the name of the camera in the scene
  44620. * @param position Define the start position of the camera in the scene
  44621. * @param scene Define the scene the camera belongs to
  44622. */
  44623. constructor(name: string, position: Vector3, scene: Scene);
  44624. /**
  44625. * Gets the current object class name.
  44626. * @return the class name
  44627. */
  44628. getClassName(): string;
  44629. }
  44630. }
  44631. declare module BABYLON {
  44632. /** @hidden */
  44633. export var passPixelShader: {
  44634. name: string;
  44635. shader: string;
  44636. };
  44637. }
  44638. declare module BABYLON {
  44639. /** @hidden */
  44640. export var passCubePixelShader: {
  44641. name: string;
  44642. shader: string;
  44643. };
  44644. }
  44645. declare module BABYLON {
  44646. /**
  44647. * PassPostProcess which produces an output the same as it's input
  44648. */
  44649. export class PassPostProcess extends PostProcess {
  44650. /**
  44651. * Creates the PassPostProcess
  44652. * @param name The name of the effect.
  44653. * @param options The required width/height ratio to downsize to before computing the render pass.
  44654. * @param camera The camera to apply the render pass to.
  44655. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  44656. * @param engine The engine which the post process will be applied. (default: current engine)
  44657. * @param reusable If the post process can be reused on the same frame. (default: false)
  44658. * @param textureType The type of texture to be used when performing the post processing.
  44659. * @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)
  44660. */
  44661. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  44662. }
  44663. /**
  44664. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  44665. */
  44666. export class PassCubePostProcess extends PostProcess {
  44667. private _face;
  44668. /**
  44669. * Gets or sets the cube face to display.
  44670. * * 0 is +X
  44671. * * 1 is -X
  44672. * * 2 is +Y
  44673. * * 3 is -Y
  44674. * * 4 is +Z
  44675. * * 5 is -Z
  44676. */
  44677. get face(): number;
  44678. set face(value: number);
  44679. /**
  44680. * Creates the PassCubePostProcess
  44681. * @param name The name of the effect.
  44682. * @param options The required width/height ratio to downsize to before computing the render pass.
  44683. * @param camera The camera to apply the render pass to.
  44684. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  44685. * @param engine The engine which the post process will be applied. (default: current engine)
  44686. * @param reusable If the post process can be reused on the same frame. (default: false)
  44687. * @param textureType The type of texture to be used when performing the post processing.
  44688. * @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)
  44689. */
  44690. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  44691. }
  44692. }
  44693. declare module BABYLON {
  44694. /** @hidden */
  44695. export var anaglyphPixelShader: {
  44696. name: string;
  44697. shader: string;
  44698. };
  44699. }
  44700. declare module BABYLON {
  44701. /**
  44702. * Postprocess used to generate anaglyphic rendering
  44703. */
  44704. export class AnaglyphPostProcess extends PostProcess {
  44705. private _passedProcess;
  44706. /**
  44707. * Creates a new AnaglyphPostProcess
  44708. * @param name defines postprocess name
  44709. * @param options defines creation options or target ratio scale
  44710. * @param rigCameras defines cameras using this postprocess
  44711. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  44712. * @param engine defines hosting engine
  44713. * @param reusable defines if the postprocess will be reused multiple times per frame
  44714. */
  44715. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  44716. }
  44717. }
  44718. declare module BABYLON {
  44719. /**
  44720. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  44721. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44722. */
  44723. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  44724. /**
  44725. * Creates a new AnaglyphArcRotateCamera
  44726. * @param name defines camera name
  44727. * @param alpha defines alpha angle (in radians)
  44728. * @param beta defines beta angle (in radians)
  44729. * @param radius defines radius
  44730. * @param target defines camera target
  44731. * @param interaxialDistance defines distance between each color axis
  44732. * @param scene defines the hosting scene
  44733. */
  44734. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  44735. /**
  44736. * Gets camera class name
  44737. * @returns AnaglyphArcRotateCamera
  44738. */
  44739. getClassName(): string;
  44740. }
  44741. }
  44742. declare module BABYLON {
  44743. /**
  44744. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  44745. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44746. */
  44747. export class AnaglyphFreeCamera extends FreeCamera {
  44748. /**
  44749. * Creates a new AnaglyphFreeCamera
  44750. * @param name defines camera name
  44751. * @param position defines initial position
  44752. * @param interaxialDistance defines distance between each color axis
  44753. * @param scene defines the hosting scene
  44754. */
  44755. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  44756. /**
  44757. * Gets camera class name
  44758. * @returns AnaglyphFreeCamera
  44759. */
  44760. getClassName(): string;
  44761. }
  44762. }
  44763. declare module BABYLON {
  44764. /**
  44765. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  44766. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44767. */
  44768. export class AnaglyphGamepadCamera extends GamepadCamera {
  44769. /**
  44770. * Creates a new AnaglyphGamepadCamera
  44771. * @param name defines camera name
  44772. * @param position defines initial position
  44773. * @param interaxialDistance defines distance between each color axis
  44774. * @param scene defines the hosting scene
  44775. */
  44776. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  44777. /**
  44778. * Gets camera class name
  44779. * @returns AnaglyphGamepadCamera
  44780. */
  44781. getClassName(): string;
  44782. }
  44783. }
  44784. declare module BABYLON {
  44785. /**
  44786. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  44787. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44788. */
  44789. export class AnaglyphUniversalCamera extends UniversalCamera {
  44790. /**
  44791. * Creates a new AnaglyphUniversalCamera
  44792. * @param name defines camera name
  44793. * @param position defines initial position
  44794. * @param interaxialDistance defines distance between each color axis
  44795. * @param scene defines the hosting scene
  44796. */
  44797. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  44798. /**
  44799. * Gets camera class name
  44800. * @returns AnaglyphUniversalCamera
  44801. */
  44802. getClassName(): string;
  44803. }
  44804. }
  44805. declare module BABYLON {
  44806. /**
  44807. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  44808. * @see http://doc.babylonjs.com/features/cameras
  44809. */
  44810. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  44811. /**
  44812. * Creates a new StereoscopicArcRotateCamera
  44813. * @param name defines camera name
  44814. * @param alpha defines alpha angle (in radians)
  44815. * @param beta defines beta angle (in radians)
  44816. * @param radius defines radius
  44817. * @param target defines camera target
  44818. * @param interaxialDistance defines distance between each color axis
  44819. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  44820. * @param scene defines the hosting scene
  44821. */
  44822. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  44823. /**
  44824. * Gets camera class name
  44825. * @returns StereoscopicArcRotateCamera
  44826. */
  44827. getClassName(): string;
  44828. }
  44829. }
  44830. declare module BABYLON {
  44831. /**
  44832. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  44833. * @see http://doc.babylonjs.com/features/cameras
  44834. */
  44835. export class StereoscopicFreeCamera extends FreeCamera {
  44836. /**
  44837. * Creates a new StereoscopicFreeCamera
  44838. * @param name defines camera name
  44839. * @param position defines initial position
  44840. * @param interaxialDistance defines distance between each color axis
  44841. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  44842. * @param scene defines the hosting scene
  44843. */
  44844. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  44845. /**
  44846. * Gets camera class name
  44847. * @returns StereoscopicFreeCamera
  44848. */
  44849. getClassName(): string;
  44850. }
  44851. }
  44852. declare module BABYLON {
  44853. /**
  44854. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  44855. * @see http://doc.babylonjs.com/features/cameras
  44856. */
  44857. export class StereoscopicGamepadCamera extends GamepadCamera {
  44858. /**
  44859. * Creates a new StereoscopicGamepadCamera
  44860. * @param name defines camera name
  44861. * @param position defines initial position
  44862. * @param interaxialDistance defines distance between each color axis
  44863. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  44864. * @param scene defines the hosting scene
  44865. */
  44866. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  44867. /**
  44868. * Gets camera class name
  44869. * @returns StereoscopicGamepadCamera
  44870. */
  44871. getClassName(): string;
  44872. }
  44873. }
  44874. declare module BABYLON {
  44875. /**
  44876. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  44877. * @see http://doc.babylonjs.com/features/cameras
  44878. */
  44879. export class StereoscopicUniversalCamera extends UniversalCamera {
  44880. /**
  44881. * Creates a new StereoscopicUniversalCamera
  44882. * @param name defines camera name
  44883. * @param position defines initial position
  44884. * @param interaxialDistance defines distance between each color axis
  44885. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  44886. * @param scene defines the hosting scene
  44887. */
  44888. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  44889. /**
  44890. * Gets camera class name
  44891. * @returns StereoscopicUniversalCamera
  44892. */
  44893. getClassName(): string;
  44894. }
  44895. }
  44896. declare module BABYLON {
  44897. /**
  44898. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  44899. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  44900. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  44901. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  44902. */
  44903. export class VirtualJoysticksCamera extends FreeCamera {
  44904. /**
  44905. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  44906. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  44907. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  44908. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  44909. * @param name Define the name of the camera in the scene
  44910. * @param position Define the start position of the camera in the scene
  44911. * @param scene Define the scene the camera belongs to
  44912. */
  44913. constructor(name: string, position: Vector3, scene: Scene);
  44914. /**
  44915. * Gets the current object class name.
  44916. * @return the class name
  44917. */
  44918. getClassName(): string;
  44919. }
  44920. }
  44921. declare module BABYLON {
  44922. /**
  44923. * This represents all the required metrics to create a VR camera.
  44924. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  44925. */
  44926. export class VRCameraMetrics {
  44927. /**
  44928. * Define the horizontal resolution off the screen.
  44929. */
  44930. hResolution: number;
  44931. /**
  44932. * Define the vertical resolution off the screen.
  44933. */
  44934. vResolution: number;
  44935. /**
  44936. * Define the horizontal screen size.
  44937. */
  44938. hScreenSize: number;
  44939. /**
  44940. * Define the vertical screen size.
  44941. */
  44942. vScreenSize: number;
  44943. /**
  44944. * Define the vertical screen center position.
  44945. */
  44946. vScreenCenter: number;
  44947. /**
  44948. * Define the distance of the eyes to the screen.
  44949. */
  44950. eyeToScreenDistance: number;
  44951. /**
  44952. * Define the distance between both lenses
  44953. */
  44954. lensSeparationDistance: number;
  44955. /**
  44956. * Define the distance between both viewer's eyes.
  44957. */
  44958. interpupillaryDistance: number;
  44959. /**
  44960. * Define the distortion factor of the VR postprocess.
  44961. * Please, touch with care.
  44962. */
  44963. distortionK: number[];
  44964. /**
  44965. * Define the chromatic aberration correction factors for the VR post process.
  44966. */
  44967. chromaAbCorrection: number[];
  44968. /**
  44969. * Define the scale factor of the post process.
  44970. * The smaller the better but the slower.
  44971. */
  44972. postProcessScaleFactor: number;
  44973. /**
  44974. * Define an offset for the lens center.
  44975. */
  44976. lensCenterOffset: number;
  44977. /**
  44978. * Define if the current vr camera should compensate the distortion of the lense or not.
  44979. */
  44980. compensateDistortion: boolean;
  44981. /**
  44982. * Defines if multiview should be enabled when rendering (Default: false)
  44983. */
  44984. multiviewEnabled: boolean;
  44985. /**
  44986. * Gets the rendering aspect ratio based on the provided resolutions.
  44987. */
  44988. get aspectRatio(): number;
  44989. /**
  44990. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  44991. */
  44992. get aspectRatioFov(): number;
  44993. /**
  44994. * @hidden
  44995. */
  44996. get leftHMatrix(): Matrix;
  44997. /**
  44998. * @hidden
  44999. */
  45000. get rightHMatrix(): Matrix;
  45001. /**
  45002. * @hidden
  45003. */
  45004. get leftPreViewMatrix(): Matrix;
  45005. /**
  45006. * @hidden
  45007. */
  45008. get rightPreViewMatrix(): Matrix;
  45009. /**
  45010. * Get the default VRMetrics based on the most generic setup.
  45011. * @returns the default vr metrics
  45012. */
  45013. static GetDefault(): VRCameraMetrics;
  45014. }
  45015. }
  45016. declare module BABYLON {
  45017. /** @hidden */
  45018. export var vrDistortionCorrectionPixelShader: {
  45019. name: string;
  45020. shader: string;
  45021. };
  45022. }
  45023. declare module BABYLON {
  45024. /**
  45025. * VRDistortionCorrectionPostProcess used for mobile VR
  45026. */
  45027. export class VRDistortionCorrectionPostProcess extends PostProcess {
  45028. private _isRightEye;
  45029. private _distortionFactors;
  45030. private _postProcessScaleFactor;
  45031. private _lensCenterOffset;
  45032. private _scaleIn;
  45033. private _scaleFactor;
  45034. private _lensCenter;
  45035. /**
  45036. * Initializes the VRDistortionCorrectionPostProcess
  45037. * @param name The name of the effect.
  45038. * @param camera The camera to apply the render pass to.
  45039. * @param isRightEye If this is for the right eye distortion
  45040. * @param vrMetrics All the required metrics for the VR camera
  45041. */
  45042. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  45043. }
  45044. }
  45045. declare module BABYLON {
  45046. /**
  45047. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  45048. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45049. */
  45050. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  45051. /**
  45052. * Creates a new VRDeviceOrientationArcRotateCamera
  45053. * @param name defines camera name
  45054. * @param alpha defines the camera rotation along the logitudinal axis
  45055. * @param beta defines the camera rotation along the latitudinal axis
  45056. * @param radius defines the camera distance from its target
  45057. * @param target defines the camera target
  45058. * @param scene defines the scene the camera belongs to
  45059. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45060. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45061. */
  45062. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45063. /**
  45064. * Gets camera class name
  45065. * @returns VRDeviceOrientationArcRotateCamera
  45066. */
  45067. getClassName(): string;
  45068. }
  45069. }
  45070. declare module BABYLON {
  45071. /**
  45072. * Camera used to simulate VR rendering (based on FreeCamera)
  45073. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45074. */
  45075. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  45076. /**
  45077. * Creates a new VRDeviceOrientationFreeCamera
  45078. * @param name defines camera name
  45079. * @param position defines the start position of the camera
  45080. * @param scene defines the scene the camera belongs to
  45081. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45082. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45083. */
  45084. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45085. /**
  45086. * Gets camera class name
  45087. * @returns VRDeviceOrientationFreeCamera
  45088. */
  45089. getClassName(): string;
  45090. }
  45091. }
  45092. declare module BABYLON {
  45093. /**
  45094. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  45095. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45096. */
  45097. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  45098. /**
  45099. * Creates a new VRDeviceOrientationGamepadCamera
  45100. * @param name defines camera name
  45101. * @param position defines the start position of the camera
  45102. * @param scene defines the scene the camera belongs to
  45103. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45104. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45105. */
  45106. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45107. /**
  45108. * Gets camera class name
  45109. * @returns VRDeviceOrientationGamepadCamera
  45110. */
  45111. getClassName(): string;
  45112. }
  45113. }
  45114. declare module BABYLON {
  45115. /** @hidden */
  45116. export var imageProcessingPixelShader: {
  45117. name: string;
  45118. shader: string;
  45119. };
  45120. }
  45121. declare module BABYLON {
  45122. /**
  45123. * ImageProcessingPostProcess
  45124. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  45125. */
  45126. export class ImageProcessingPostProcess extends PostProcess {
  45127. /**
  45128. * Default configuration related to image processing available in the PBR Material.
  45129. */
  45130. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45131. /**
  45132. * Gets the image processing configuration used either in this material.
  45133. */
  45134. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  45135. /**
  45136. * Sets the Default image processing configuration used either in the this material.
  45137. *
  45138. * If sets to null, the scene one is in use.
  45139. */
  45140. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  45141. /**
  45142. * Keep track of the image processing observer to allow dispose and replace.
  45143. */
  45144. private _imageProcessingObserver;
  45145. /**
  45146. * Attaches a new image processing configuration to the PBR Material.
  45147. * @param configuration
  45148. */
  45149. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  45150. /**
  45151. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45152. */
  45153. get colorCurves(): Nullable<ColorCurves>;
  45154. /**
  45155. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45156. */
  45157. set colorCurves(value: Nullable<ColorCurves>);
  45158. /**
  45159. * Gets wether the color curves effect is enabled.
  45160. */
  45161. get colorCurvesEnabled(): boolean;
  45162. /**
  45163. * Sets wether the color curves effect is enabled.
  45164. */
  45165. set colorCurvesEnabled(value: boolean);
  45166. /**
  45167. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45168. */
  45169. get colorGradingTexture(): Nullable<BaseTexture>;
  45170. /**
  45171. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45172. */
  45173. set colorGradingTexture(value: Nullable<BaseTexture>);
  45174. /**
  45175. * Gets wether the color grading effect is enabled.
  45176. */
  45177. get colorGradingEnabled(): boolean;
  45178. /**
  45179. * Gets wether the color grading effect is enabled.
  45180. */
  45181. set colorGradingEnabled(value: boolean);
  45182. /**
  45183. * Gets exposure used in the effect.
  45184. */
  45185. get exposure(): number;
  45186. /**
  45187. * Sets exposure used in the effect.
  45188. */
  45189. set exposure(value: number);
  45190. /**
  45191. * Gets wether tonemapping is enabled or not.
  45192. */
  45193. get toneMappingEnabled(): boolean;
  45194. /**
  45195. * Sets wether tonemapping is enabled or not
  45196. */
  45197. set toneMappingEnabled(value: boolean);
  45198. /**
  45199. * Gets the type of tone mapping effect.
  45200. */
  45201. get toneMappingType(): number;
  45202. /**
  45203. * Sets the type of tone mapping effect.
  45204. */
  45205. set toneMappingType(value: number);
  45206. /**
  45207. * Gets contrast used in the effect.
  45208. */
  45209. get contrast(): number;
  45210. /**
  45211. * Sets contrast used in the effect.
  45212. */
  45213. set contrast(value: number);
  45214. /**
  45215. * Gets Vignette stretch size.
  45216. */
  45217. get vignetteStretch(): number;
  45218. /**
  45219. * Sets Vignette stretch size.
  45220. */
  45221. set vignetteStretch(value: number);
  45222. /**
  45223. * Gets Vignette centre X Offset.
  45224. */
  45225. get vignetteCentreX(): number;
  45226. /**
  45227. * Sets Vignette centre X Offset.
  45228. */
  45229. set vignetteCentreX(value: number);
  45230. /**
  45231. * Gets Vignette centre Y Offset.
  45232. */
  45233. get vignetteCentreY(): number;
  45234. /**
  45235. * Sets Vignette centre Y Offset.
  45236. */
  45237. set vignetteCentreY(value: number);
  45238. /**
  45239. * Gets Vignette weight or intensity of the vignette effect.
  45240. */
  45241. get vignetteWeight(): number;
  45242. /**
  45243. * Sets Vignette weight or intensity of the vignette effect.
  45244. */
  45245. set vignetteWeight(value: number);
  45246. /**
  45247. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45248. * if vignetteEnabled is set to true.
  45249. */
  45250. get vignetteColor(): Color4;
  45251. /**
  45252. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45253. * if vignetteEnabled is set to true.
  45254. */
  45255. set vignetteColor(value: Color4);
  45256. /**
  45257. * Gets Camera field of view used by the Vignette effect.
  45258. */
  45259. get vignetteCameraFov(): number;
  45260. /**
  45261. * Sets Camera field of view used by the Vignette effect.
  45262. */
  45263. set vignetteCameraFov(value: number);
  45264. /**
  45265. * Gets the vignette blend mode allowing different kind of effect.
  45266. */
  45267. get vignetteBlendMode(): number;
  45268. /**
  45269. * Sets the vignette blend mode allowing different kind of effect.
  45270. */
  45271. set vignetteBlendMode(value: number);
  45272. /**
  45273. * Gets wether the vignette effect is enabled.
  45274. */
  45275. get vignetteEnabled(): boolean;
  45276. /**
  45277. * Sets wether the vignette effect is enabled.
  45278. */
  45279. set vignetteEnabled(value: boolean);
  45280. private _fromLinearSpace;
  45281. /**
  45282. * Gets wether the input of the processing is in Gamma or Linear Space.
  45283. */
  45284. get fromLinearSpace(): boolean;
  45285. /**
  45286. * Sets wether the input of the processing is in Gamma or Linear Space.
  45287. */
  45288. set fromLinearSpace(value: boolean);
  45289. /**
  45290. * Defines cache preventing GC.
  45291. */
  45292. private _defines;
  45293. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  45294. /**
  45295. * "ImageProcessingPostProcess"
  45296. * @returns "ImageProcessingPostProcess"
  45297. */
  45298. getClassName(): string;
  45299. protected _updateParameters(): void;
  45300. dispose(camera?: Camera): void;
  45301. }
  45302. }
  45303. declare module BABYLON {
  45304. /**
  45305. * Class containing static functions to help procedurally build meshes
  45306. */
  45307. export class GroundBuilder {
  45308. /**
  45309. * Creates a ground mesh
  45310. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  45311. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  45312. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45313. * @param name defines the name of the mesh
  45314. * @param options defines the options used to create the mesh
  45315. * @param scene defines the hosting scene
  45316. * @returns the ground mesh
  45317. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  45318. */
  45319. static CreateGround(name: string, options: {
  45320. width?: number;
  45321. height?: number;
  45322. subdivisions?: number;
  45323. subdivisionsX?: number;
  45324. subdivisionsY?: number;
  45325. updatable?: boolean;
  45326. }, scene: any): Mesh;
  45327. /**
  45328. * Creates a tiled ground mesh
  45329. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  45330. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  45331. * * 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
  45332. * * 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
  45333. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45334. * @param name defines the name of the mesh
  45335. * @param options defines the options used to create the mesh
  45336. * @param scene defines the hosting scene
  45337. * @returns the tiled ground mesh
  45338. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  45339. */
  45340. static CreateTiledGround(name: string, options: {
  45341. xmin: number;
  45342. zmin: number;
  45343. xmax: number;
  45344. zmax: number;
  45345. subdivisions?: {
  45346. w: number;
  45347. h: number;
  45348. };
  45349. precision?: {
  45350. w: number;
  45351. h: number;
  45352. };
  45353. updatable?: boolean;
  45354. }, scene?: Nullable<Scene>): Mesh;
  45355. /**
  45356. * Creates a ground mesh from a height map
  45357. * * The parameter `url` sets the URL of the height map image resource.
  45358. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  45359. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  45360. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  45361. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  45362. * * 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.
  45363. * * 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).
  45364. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  45365. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45366. * @param name defines the name of the mesh
  45367. * @param url defines the url to the height map
  45368. * @param options defines the options used to create the mesh
  45369. * @param scene defines the hosting scene
  45370. * @returns the ground mesh
  45371. * @see https://doc.babylonjs.com/babylon101/height_map
  45372. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  45373. */
  45374. static CreateGroundFromHeightMap(name: string, url: string, options: {
  45375. width?: number;
  45376. height?: number;
  45377. subdivisions?: number;
  45378. minHeight?: number;
  45379. maxHeight?: number;
  45380. colorFilter?: Color3;
  45381. alphaFilter?: number;
  45382. updatable?: boolean;
  45383. onReady?: (mesh: GroundMesh) => void;
  45384. }, scene?: Nullable<Scene>): GroundMesh;
  45385. }
  45386. }
  45387. declare module BABYLON {
  45388. /**
  45389. * Class containing static functions to help procedurally build meshes
  45390. */
  45391. export class TorusBuilder {
  45392. /**
  45393. * Creates a torus mesh
  45394. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  45395. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  45396. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  45397. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45398. * * 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
  45399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45400. * @param name defines the name of the mesh
  45401. * @param options defines the options used to create the mesh
  45402. * @param scene defines the hosting scene
  45403. * @returns the torus mesh
  45404. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  45405. */
  45406. static CreateTorus(name: string, options: {
  45407. diameter?: number;
  45408. thickness?: number;
  45409. tessellation?: number;
  45410. updatable?: boolean;
  45411. sideOrientation?: number;
  45412. frontUVs?: Vector4;
  45413. backUVs?: Vector4;
  45414. }, scene: any): Mesh;
  45415. }
  45416. }
  45417. declare module BABYLON {
  45418. /**
  45419. * Class containing static functions to help procedurally build meshes
  45420. */
  45421. export class CylinderBuilder {
  45422. /**
  45423. * Creates a cylinder or a cone mesh
  45424. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  45425. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  45426. * * 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.
  45427. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  45428. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  45429. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  45430. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  45431. * * 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).
  45432. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  45433. * * 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).
  45434. * * 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
  45435. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  45436. * * 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
  45437. * * 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.
  45438. * * If `enclose` is false, a ring surface is one element.
  45439. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  45440. * * 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
  45441. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45442. * * 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
  45443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45444. * @param name defines the name of the mesh
  45445. * @param options defines the options used to create the mesh
  45446. * @param scene defines the hosting scene
  45447. * @returns the cylinder mesh
  45448. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  45449. */
  45450. static CreateCylinder(name: string, options: {
  45451. height?: number;
  45452. diameterTop?: number;
  45453. diameterBottom?: number;
  45454. diameter?: number;
  45455. tessellation?: number;
  45456. subdivisions?: number;
  45457. arc?: number;
  45458. faceColors?: Color4[];
  45459. faceUV?: Vector4[];
  45460. updatable?: boolean;
  45461. hasRings?: boolean;
  45462. enclose?: boolean;
  45463. cap?: number;
  45464. sideOrientation?: number;
  45465. frontUVs?: Vector4;
  45466. backUVs?: Vector4;
  45467. }, scene: any): Mesh;
  45468. }
  45469. }
  45470. declare module BABYLON {
  45471. /**
  45472. * States of the webXR experience
  45473. */
  45474. export enum WebXRState {
  45475. /**
  45476. * Transitioning to being in XR mode
  45477. */
  45478. ENTERING_XR = 0,
  45479. /**
  45480. * Transitioning to non XR mode
  45481. */
  45482. EXITING_XR = 1,
  45483. /**
  45484. * In XR mode and presenting
  45485. */
  45486. IN_XR = 2,
  45487. /**
  45488. * Not entered XR mode
  45489. */
  45490. NOT_IN_XR = 3
  45491. }
  45492. /**
  45493. * Abstraction of the XR render target
  45494. */
  45495. export interface WebXRRenderTarget extends IDisposable {
  45496. /**
  45497. * xrpresent context of the canvas which can be used to display/mirror xr content
  45498. */
  45499. canvasContext: WebGLRenderingContext;
  45500. /**
  45501. * xr layer for the canvas
  45502. */
  45503. xrLayer: Nullable<XRWebGLLayer>;
  45504. /**
  45505. * Initializes the xr layer for the session
  45506. * @param xrSession xr session
  45507. * @returns a promise that will resolve once the XR Layer has been created
  45508. */
  45509. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  45510. }
  45511. }
  45512. declare module BABYLON {
  45513. /**
  45514. * COnfiguration object for WebXR output canvas
  45515. */
  45516. export class WebXRManagedOutputCanvasOptions {
  45517. /**
  45518. * An optional canvas in case you wish to create it yourself and provide it here.
  45519. * If not provided, a new canvas will be created
  45520. */
  45521. canvasElement?: HTMLCanvasElement;
  45522. /**
  45523. * Options for this XR Layer output
  45524. */
  45525. canvasOptions?: XRWebGLLayerOptions;
  45526. /**
  45527. * CSS styling for a newly created canvas (if not provided)
  45528. */
  45529. newCanvasCssStyle?: string;
  45530. /**
  45531. * Get the default values of the configuration object
  45532. * @returns default values of this configuration object
  45533. */
  45534. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  45535. }
  45536. /**
  45537. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  45538. */
  45539. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  45540. private _options;
  45541. private _canvas;
  45542. private _engine;
  45543. /**
  45544. * Rendering context of the canvas which can be used to display/mirror xr content
  45545. */
  45546. canvasContext: WebGLRenderingContext;
  45547. /**
  45548. * xr layer for the canvas
  45549. */
  45550. xrLayer: Nullable<XRWebGLLayer>;
  45551. /**
  45552. * Initializes the canvas to be added/removed upon entering/exiting xr
  45553. * @param _xrSessionManager The XR Session manager
  45554. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  45555. */
  45556. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  45557. /**
  45558. * Disposes of the object
  45559. */
  45560. dispose(): void;
  45561. /**
  45562. * Initializes the xr layer for the session
  45563. * @param xrSession xr session
  45564. * @returns a promise that will resolve once the XR Layer has been created
  45565. */
  45566. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  45567. private _addCanvas;
  45568. private _removeCanvas;
  45569. private _setManagedOutputCanvas;
  45570. }
  45571. }
  45572. declare module BABYLON {
  45573. /**
  45574. * Manages an XRSession to work with Babylon's engine
  45575. * @see https://doc.babylonjs.com/how_to/webxr
  45576. */
  45577. export class WebXRSessionManager implements IDisposable {
  45578. /** The scene which the session should be created for */
  45579. scene: Scene;
  45580. private _referenceSpace;
  45581. private _rttProvider;
  45582. private _sessionEnded;
  45583. private _xrNavigator;
  45584. private baseLayer;
  45585. /**
  45586. * The base reference space from which the session started. good if you want to reset your
  45587. * reference space
  45588. */
  45589. baseReferenceSpace: XRReferenceSpace;
  45590. /**
  45591. * Current XR frame
  45592. */
  45593. currentFrame: Nullable<XRFrame>;
  45594. /** WebXR timestamp updated every frame */
  45595. currentTimestamp: number;
  45596. /**
  45597. * Used just in case of a failure to initialize an immersive session.
  45598. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  45599. */
  45600. defaultHeightCompensation: number;
  45601. /**
  45602. * Fires every time a new xrFrame arrives which can be used to update the camera
  45603. */
  45604. onXRFrameObservable: Observable<XRFrame>;
  45605. /**
  45606. * Fires when the reference space changed
  45607. */
  45608. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  45609. /**
  45610. * Fires when the xr session is ended either by the device or manually done
  45611. */
  45612. onXRSessionEnded: Observable<any>;
  45613. /**
  45614. * Fires when the xr session is ended either by the device or manually done
  45615. */
  45616. onXRSessionInit: Observable<XRSession>;
  45617. /**
  45618. * Underlying xr session
  45619. */
  45620. session: XRSession;
  45621. /**
  45622. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  45623. * or get the offset the player is currently at.
  45624. */
  45625. viewerReferenceSpace: XRReferenceSpace;
  45626. /**
  45627. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  45628. * @param scene The scene which the session should be created for
  45629. */
  45630. constructor(
  45631. /** The scene which the session should be created for */
  45632. scene: Scene);
  45633. /**
  45634. * The current reference space used in this session. This reference space can constantly change!
  45635. * It is mainly used to offset the camera's position.
  45636. */
  45637. get referenceSpace(): XRReferenceSpace;
  45638. /**
  45639. * Set a new reference space and triggers the observable
  45640. */
  45641. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  45642. /**
  45643. * Disposes of the session manager
  45644. */
  45645. dispose(): void;
  45646. /**
  45647. * Stops the xrSession and restores the render loop
  45648. * @returns Promise which resolves after it exits XR
  45649. */
  45650. exitXRAsync(): Promise<void>;
  45651. /**
  45652. * Gets the correct render target texture to be rendered this frame for this eye
  45653. * @param eye the eye for which to get the render target
  45654. * @returns the render target for the specified eye
  45655. */
  45656. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  45657. /**
  45658. * Creates a WebXRRenderTarget object for the XR session
  45659. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  45660. * @param options optional options to provide when creating a new render target
  45661. * @returns a WebXR render target to which the session can render
  45662. */
  45663. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  45664. /**
  45665. * Initializes the manager
  45666. * After initialization enterXR can be called to start an XR session
  45667. * @returns Promise which resolves after it is initialized
  45668. */
  45669. initializeAsync(): Promise<void>;
  45670. /**
  45671. * Initializes an xr session
  45672. * @param xrSessionMode mode to initialize
  45673. * @param xrSessionInit defines optional and required values to pass to the session builder
  45674. * @returns a promise which will resolve once the session has been initialized
  45675. */
  45676. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  45677. /**
  45678. * Checks if a session would be supported for the creation options specified
  45679. * @param sessionMode session mode to check if supported eg. immersive-vr
  45680. * @returns A Promise that resolves to true if supported and false if not
  45681. */
  45682. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  45683. /**
  45684. * Resets the reference space to the one started the session
  45685. */
  45686. resetReferenceSpace(): void;
  45687. /**
  45688. * Starts rendering to the xr layer
  45689. */
  45690. runXRRenderLoop(): void;
  45691. /**
  45692. * Sets the reference space on the xr session
  45693. * @param referenceSpaceType space to set
  45694. * @returns a promise that will resolve once the reference space has been set
  45695. */
  45696. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  45697. /**
  45698. * Updates the render state of the session
  45699. * @param state state to set
  45700. * @returns a promise that resolves once the render state has been updated
  45701. */
  45702. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  45703. /**
  45704. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  45705. * @param sessionMode defines the session to test
  45706. * @returns a promise with boolean as final value
  45707. */
  45708. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  45709. private _createRenderTargetTexture;
  45710. }
  45711. }
  45712. declare module BABYLON {
  45713. /**
  45714. * WebXR Camera which holds the views for the xrSession
  45715. * @see https://doc.babylonjs.com/how_to/webxr_camera
  45716. */
  45717. export class WebXRCamera extends FreeCamera {
  45718. private _xrSessionManager;
  45719. private _firstFrame;
  45720. private _referenceQuaternion;
  45721. private _referencedPosition;
  45722. private _xrInvPositionCache;
  45723. private _xrInvQuaternionCache;
  45724. /**
  45725. * Should position compensation execute on first frame.
  45726. * This is used when copying the position from a native (non XR) camera
  45727. */
  45728. compensateOnFirstFrame: boolean;
  45729. /**
  45730. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  45731. * @param name the name of the camera
  45732. * @param scene the scene to add the camera to
  45733. * @param _xrSessionManager a constructed xr session manager
  45734. */
  45735. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  45736. /**
  45737. * Return the user's height, unrelated to the current ground.
  45738. * This will be the y position of this camera, when ground level is 0.
  45739. */
  45740. get realWorldHeight(): number;
  45741. /** @hidden */
  45742. _updateForDualEyeDebugging(): void;
  45743. /**
  45744. * Sets this camera's transformation based on a non-vr camera
  45745. * @param otherCamera the non-vr camera to copy the transformation from
  45746. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  45747. */
  45748. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  45749. /**
  45750. * Gets the current instance class name ("WebXRCamera").
  45751. * @returns the class name
  45752. */
  45753. getClassName(): string;
  45754. /**
  45755. * Overriding the _getViewMatrix function, as it is computed by WebXR
  45756. */
  45757. _getViewMatrix(): Matrix;
  45758. private _updateFromXRSession;
  45759. private _updateNumberOfRigCameras;
  45760. private _updateReferenceSpace;
  45761. private _updateReferenceSpaceOffset;
  45762. }
  45763. }
  45764. declare module BABYLON {
  45765. /**
  45766. * Defining the interface required for a (webxr) feature
  45767. */
  45768. export interface IWebXRFeature extends IDisposable {
  45769. /**
  45770. * Is this feature attached
  45771. */
  45772. attached: boolean;
  45773. /**
  45774. * Should auto-attach be disabled?
  45775. */
  45776. disableAutoAttach: boolean;
  45777. /**
  45778. * Attach the feature to the session
  45779. * Will usually be called by the features manager
  45780. *
  45781. * @param force should attachment be forced (even when already attached)
  45782. * @returns true if successful.
  45783. */
  45784. attach(force?: boolean): boolean;
  45785. /**
  45786. * Detach the feature from the session
  45787. * Will usually be called by the features manager
  45788. *
  45789. * @returns true if successful.
  45790. */
  45791. detach(): boolean;
  45792. }
  45793. /**
  45794. * A list of the currently available features without referencing them
  45795. */
  45796. export class WebXRFeatureName {
  45797. /**
  45798. * The name of the anchor system feature
  45799. */
  45800. static ANCHOR_SYSTEM: string;
  45801. /**
  45802. * The name of the background remover feature
  45803. */
  45804. static BACKGROUND_REMOVER: string;
  45805. /**
  45806. * The name of the hit test feature
  45807. */
  45808. static HIT_TEST: string;
  45809. /**
  45810. * physics impostors for xr controllers feature
  45811. */
  45812. static PHYSICS_CONTROLLERS: string;
  45813. /**
  45814. * The name of the plane detection feature
  45815. */
  45816. static PLANE_DETECTION: string;
  45817. /**
  45818. * The name of the pointer selection feature
  45819. */
  45820. static POINTER_SELECTION: string;
  45821. /**
  45822. * The name of the teleportation feature
  45823. */
  45824. static TELEPORTATION: string;
  45825. }
  45826. /**
  45827. * Defining the constructor of a feature. Used to register the modules.
  45828. */
  45829. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  45830. /**
  45831. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  45832. * It is mainly used in AR sessions.
  45833. *
  45834. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  45835. */
  45836. export class WebXRFeaturesManager implements IDisposable {
  45837. private _xrSessionManager;
  45838. private static readonly _AvailableFeatures;
  45839. private _features;
  45840. /**
  45841. * constructs a new features manages.
  45842. *
  45843. * @param _xrSessionManager an instance of WebXRSessionManager
  45844. */
  45845. constructor(_xrSessionManager: WebXRSessionManager);
  45846. /**
  45847. * Used to register a module. After calling this function a developer can use this feature in the scene.
  45848. * Mainly used internally.
  45849. *
  45850. * @param featureName the name of the feature to register
  45851. * @param constructorFunction the function used to construct the module
  45852. * @param version the (babylon) version of the module
  45853. * @param stable is that a stable version of this module
  45854. */
  45855. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  45856. /**
  45857. * Returns a constructor of a specific feature.
  45858. *
  45859. * @param featureName the name of the feature to construct
  45860. * @param version the version of the feature to load
  45861. * @param xrSessionManager the xrSessionManager. Used to construct the module
  45862. * @param options optional options provided to the module.
  45863. * @returns a function that, when called, will return a new instance of this feature
  45864. */
  45865. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  45866. /**
  45867. * Can be used to return the list of features currently registered
  45868. *
  45869. * @returns an Array of available features
  45870. */
  45871. static GetAvailableFeatures(): string[];
  45872. /**
  45873. * Gets the versions available for a specific feature
  45874. * @param featureName the name of the feature
  45875. * @returns an array with the available versions
  45876. */
  45877. static GetAvailableVersions(featureName: string): string[];
  45878. /**
  45879. * Return the latest unstable version of this feature
  45880. * @param featureName the name of the feature to search
  45881. * @returns the version number. if not found will return -1
  45882. */
  45883. static GetLatestVersionOfFeature(featureName: string): number;
  45884. /**
  45885. * Return the latest stable version of this feature
  45886. * @param featureName the name of the feature to search
  45887. * @returns the version number. if not found will return -1
  45888. */
  45889. static GetStableVersionOfFeature(featureName: string): number;
  45890. /**
  45891. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  45892. * Can be used during a session to start a feature
  45893. * @param featureName the name of feature to attach
  45894. */
  45895. attachFeature(featureName: string): void;
  45896. /**
  45897. * Can be used inside a session or when the session ends to detach a specific feature
  45898. * @param featureName the name of the feature to detach
  45899. */
  45900. detachFeature(featureName: string): void;
  45901. /**
  45902. * Used to disable an already-enabled feature
  45903. * The feature will be disposed and will be recreated once enabled.
  45904. * @param featureName the feature to disable
  45905. * @returns true if disable was successful
  45906. */
  45907. disableFeature(featureName: string | {
  45908. Name: string;
  45909. }): boolean;
  45910. /**
  45911. * dispose this features manager
  45912. */
  45913. dispose(): void;
  45914. /**
  45915. * 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.
  45916. * 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.
  45917. *
  45918. * @param featureName the name of the feature to load or the class of the feature
  45919. * @param version optional version to load. if not provided the latest version will be enabled
  45920. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  45921. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  45922. * @returns a new constructed feature or throws an error if feature not found.
  45923. */
  45924. enableFeature(featureName: string | {
  45925. Name: string;
  45926. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  45927. /**
  45928. * get the implementation of an enabled feature.
  45929. * @param featureName the name of the feature to load
  45930. * @returns the feature class, if found
  45931. */
  45932. getEnabledFeature(featureName: string): IWebXRFeature;
  45933. /**
  45934. * Get the list of enabled features
  45935. * @returns an array of enabled features
  45936. */
  45937. getEnabledFeatures(): string[];
  45938. }
  45939. }
  45940. declare module BABYLON {
  45941. /**
  45942. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  45943. * @see https://doc.babylonjs.com/how_to/webxr
  45944. */
  45945. export class WebXRExperienceHelper implements IDisposable {
  45946. private scene;
  45947. private _nonVRCamera;
  45948. private _originalSceneAutoClear;
  45949. private _supported;
  45950. /**
  45951. * Camera used to render xr content
  45952. */
  45953. camera: WebXRCamera;
  45954. /** A features manager for this xr session */
  45955. featuresManager: WebXRFeaturesManager;
  45956. /**
  45957. * Observers registered here will be triggered after the camera's initial transformation is set
  45958. * This can be used to set a different ground level or an extra rotation.
  45959. *
  45960. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  45961. * to the position set after this observable is done executing.
  45962. */
  45963. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  45964. /**
  45965. * Fires when the state of the experience helper has changed
  45966. */
  45967. onStateChangedObservable: Observable<WebXRState>;
  45968. /** Session manager used to keep track of xr session */
  45969. sessionManager: WebXRSessionManager;
  45970. /**
  45971. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  45972. */
  45973. state: WebXRState;
  45974. /**
  45975. * Creates a WebXRExperienceHelper
  45976. * @param scene The scene the helper should be created in
  45977. */
  45978. private constructor();
  45979. /**
  45980. * Creates the experience helper
  45981. * @param scene the scene to attach the experience helper to
  45982. * @returns a promise for the experience helper
  45983. */
  45984. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  45985. /**
  45986. * Disposes of the experience helper
  45987. */
  45988. dispose(): void;
  45989. /**
  45990. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  45991. * @param sessionMode options for the XR session
  45992. * @param referenceSpaceType frame of reference of the XR session
  45993. * @param renderTarget the output canvas that will be used to enter XR mode
  45994. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  45995. * @returns promise that resolves after xr mode has entered
  45996. */
  45997. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  45998. /**
  45999. * Exits XR mode and returns the scene to its original state
  46000. * @returns promise that resolves after xr mode has exited
  46001. */
  46002. exitXRAsync(): Promise<void>;
  46003. private _nonXRToXRCamera;
  46004. private _setState;
  46005. }
  46006. }
  46007. declare module BABYLON {
  46008. /**
  46009. * X-Y values for axes in WebXR
  46010. */
  46011. export interface IWebXRMotionControllerAxesValue {
  46012. /**
  46013. * The value of the x axis
  46014. */
  46015. x: number;
  46016. /**
  46017. * The value of the y-axis
  46018. */
  46019. y: number;
  46020. }
  46021. /**
  46022. * changed / previous values for the values of this component
  46023. */
  46024. export interface IWebXRMotionControllerComponentChangesValues<T> {
  46025. /**
  46026. * current (this frame) value
  46027. */
  46028. current: T;
  46029. /**
  46030. * previous (last change) value
  46031. */
  46032. previous: T;
  46033. }
  46034. /**
  46035. * Represents changes in the component between current frame and last values recorded
  46036. */
  46037. export interface IWebXRMotionControllerComponentChanges {
  46038. /**
  46039. * will be populated with previous and current values if axes changed
  46040. */
  46041. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  46042. /**
  46043. * will be populated with previous and current values if pressed changed
  46044. */
  46045. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46046. /**
  46047. * will be populated with previous and current values if touched changed
  46048. */
  46049. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46050. /**
  46051. * will be populated with previous and current values if value changed
  46052. */
  46053. value?: IWebXRMotionControllerComponentChangesValues<number>;
  46054. }
  46055. /**
  46056. * This class represents a single component (for example button or thumbstick) of a motion controller
  46057. */
  46058. export class WebXRControllerComponent implements IDisposable {
  46059. /**
  46060. * the id of this component
  46061. */
  46062. id: string;
  46063. /**
  46064. * the type of the component
  46065. */
  46066. type: MotionControllerComponentType;
  46067. private _buttonIndex;
  46068. private _axesIndices;
  46069. private _axes;
  46070. private _changes;
  46071. private _currentValue;
  46072. private _hasChanges;
  46073. private _pressed;
  46074. private _touched;
  46075. /**
  46076. * button component type
  46077. */
  46078. static BUTTON_TYPE: MotionControllerComponentType;
  46079. /**
  46080. * squeeze component type
  46081. */
  46082. static SQUEEZE_TYPE: MotionControllerComponentType;
  46083. /**
  46084. * Thumbstick component type
  46085. */
  46086. static THUMBSTICK_TYPE: MotionControllerComponentType;
  46087. /**
  46088. * Touchpad component type
  46089. */
  46090. static TOUCHPAD_TYPE: MotionControllerComponentType;
  46091. /**
  46092. * trigger component type
  46093. */
  46094. static TRIGGER_TYPE: MotionControllerComponentType;
  46095. /**
  46096. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  46097. * the axes data changes
  46098. */
  46099. onAxisValueChangedObservable: Observable<{
  46100. x: number;
  46101. y: number;
  46102. }>;
  46103. /**
  46104. * Observers registered here will be triggered when the state of a button changes
  46105. * State change is either pressed / touched / value
  46106. */
  46107. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  46108. /**
  46109. * Creates a new component for a motion controller.
  46110. * It is created by the motion controller itself
  46111. *
  46112. * @param id the id of this component
  46113. * @param type the type of the component
  46114. * @param _buttonIndex index in the buttons array of the gamepad
  46115. * @param _axesIndices indices of the values in the axes array of the gamepad
  46116. */
  46117. constructor(
  46118. /**
  46119. * the id of this component
  46120. */
  46121. id: string,
  46122. /**
  46123. * the type of the component
  46124. */
  46125. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  46126. /**
  46127. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  46128. */
  46129. get axes(): IWebXRMotionControllerAxesValue;
  46130. /**
  46131. * Get the changes. Elements will be populated only if they changed with their previous and current value
  46132. */
  46133. get changes(): IWebXRMotionControllerComponentChanges;
  46134. /**
  46135. * Return whether or not the component changed the last frame
  46136. */
  46137. get hasChanges(): boolean;
  46138. /**
  46139. * is the button currently pressed
  46140. */
  46141. get pressed(): boolean;
  46142. /**
  46143. * is the button currently touched
  46144. */
  46145. get touched(): boolean;
  46146. /**
  46147. * Get the current value of this component
  46148. */
  46149. get value(): number;
  46150. /**
  46151. * Dispose this component
  46152. */
  46153. dispose(): void;
  46154. /**
  46155. * Are there axes correlating to this component
  46156. * @return true is axes data is available
  46157. */
  46158. isAxes(): boolean;
  46159. /**
  46160. * Is this component a button (hence - pressable)
  46161. * @returns true if can be pressed
  46162. */
  46163. isButton(): boolean;
  46164. /**
  46165. * update this component using the gamepad object it is in. Called on every frame
  46166. * @param nativeController the native gamepad controller object
  46167. */
  46168. update(nativeController: IMinimalMotionControllerObject): void;
  46169. }
  46170. }
  46171. declare module BABYLON {
  46172. /**
  46173. * Class used to represent data loading progression
  46174. */
  46175. export class SceneLoaderProgressEvent {
  46176. /** defines if data length to load can be evaluated */
  46177. readonly lengthComputable: boolean;
  46178. /** defines the loaded data length */
  46179. readonly loaded: number;
  46180. /** defines the data length to load */
  46181. readonly total: number;
  46182. /**
  46183. * Create a new progress event
  46184. * @param lengthComputable defines if data length to load can be evaluated
  46185. * @param loaded defines the loaded data length
  46186. * @param total defines the data length to load
  46187. */
  46188. constructor(
  46189. /** defines if data length to load can be evaluated */
  46190. lengthComputable: boolean,
  46191. /** defines the loaded data length */
  46192. loaded: number,
  46193. /** defines the data length to load */
  46194. total: number);
  46195. /**
  46196. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  46197. * @param event defines the source event
  46198. * @returns a new SceneLoaderProgressEvent
  46199. */
  46200. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  46201. }
  46202. /**
  46203. * Interface used by SceneLoader plugins to define supported file extensions
  46204. */
  46205. export interface ISceneLoaderPluginExtensions {
  46206. /**
  46207. * Defines the list of supported extensions
  46208. */
  46209. [extension: string]: {
  46210. isBinary: boolean;
  46211. };
  46212. }
  46213. /**
  46214. * Interface used by SceneLoader plugin factory
  46215. */
  46216. export interface ISceneLoaderPluginFactory {
  46217. /**
  46218. * Defines the name of the factory
  46219. */
  46220. name: string;
  46221. /**
  46222. * Function called to create a new plugin
  46223. * @return the new plugin
  46224. */
  46225. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  46226. /**
  46227. * The callback that returns true if the data can be directly loaded.
  46228. * @param data string containing the file data
  46229. * @returns if the data can be loaded directly
  46230. */
  46231. canDirectLoad?(data: string): boolean;
  46232. }
  46233. /**
  46234. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  46235. */
  46236. export interface ISceneLoaderPluginBase {
  46237. /**
  46238. * The friendly name of this plugin.
  46239. */
  46240. name: string;
  46241. /**
  46242. * The file extensions supported by this plugin.
  46243. */
  46244. extensions: string | ISceneLoaderPluginExtensions;
  46245. /**
  46246. * The callback called when loading from a url.
  46247. * @param scene scene loading this url
  46248. * @param url url to load
  46249. * @param onSuccess callback called when the file successfully loads
  46250. * @param onProgress callback called while file is loading (if the server supports this mode)
  46251. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  46252. * @param onError callback called when the file fails to load
  46253. * @returns a file request object
  46254. */
  46255. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46256. /**
  46257. * The callback called when loading from a file object.
  46258. * @param scene scene loading this file
  46259. * @param file defines the file to load
  46260. * @param onSuccess defines the callback to call when data is loaded
  46261. * @param onProgress defines the callback to call during loading process
  46262. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  46263. * @param onError defines the callback to call when an error occurs
  46264. * @returns a file request object
  46265. */
  46266. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46267. /**
  46268. * The callback that returns true if the data can be directly loaded.
  46269. * @param data string containing the file data
  46270. * @returns if the data can be loaded directly
  46271. */
  46272. canDirectLoad?(data: string): boolean;
  46273. /**
  46274. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  46275. * @param scene scene loading this data
  46276. * @param data string containing the data
  46277. * @returns data to pass to the plugin
  46278. */
  46279. directLoad?(scene: Scene, data: string): any;
  46280. /**
  46281. * The callback that allows custom handling of the root url based on the response url.
  46282. * @param rootUrl the original root url
  46283. * @param responseURL the response url if available
  46284. * @returns the new root url
  46285. */
  46286. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  46287. }
  46288. /**
  46289. * Interface used to define a SceneLoader plugin
  46290. */
  46291. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  46292. /**
  46293. * Import meshes into a scene.
  46294. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46295. * @param scene The scene to import into
  46296. * @param data The data to import
  46297. * @param rootUrl The root url for scene and resources
  46298. * @param meshes The meshes array to import into
  46299. * @param particleSystems The particle systems array to import into
  46300. * @param skeletons The skeletons array to import into
  46301. * @param onError The callback when import fails
  46302. * @returns True if successful or false otherwise
  46303. */
  46304. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  46305. /**
  46306. * Load into a scene.
  46307. * @param scene The scene to load into
  46308. * @param data The data to import
  46309. * @param rootUrl The root url for scene and resources
  46310. * @param onError The callback when import fails
  46311. * @returns True if successful or false otherwise
  46312. */
  46313. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  46314. /**
  46315. * Load into an asset container.
  46316. * @param scene The scene to load into
  46317. * @param data The data to import
  46318. * @param rootUrl The root url for scene and resources
  46319. * @param onError The callback when import fails
  46320. * @returns The loaded asset container
  46321. */
  46322. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  46323. }
  46324. /**
  46325. * Interface used to define an async SceneLoader plugin
  46326. */
  46327. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  46328. /**
  46329. * Import meshes into a scene.
  46330. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46331. * @param scene The scene to import into
  46332. * @param data The data to import
  46333. * @param rootUrl The root url for scene and resources
  46334. * @param onProgress The callback when the load progresses
  46335. * @param fileName Defines the name of the file to load
  46336. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  46337. */
  46338. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  46339. meshes: AbstractMesh[];
  46340. particleSystems: IParticleSystem[];
  46341. skeletons: Skeleton[];
  46342. animationGroups: AnimationGroup[];
  46343. }>;
  46344. /**
  46345. * Load into a scene.
  46346. * @param scene The scene to load into
  46347. * @param data The data to import
  46348. * @param rootUrl The root url for scene and resources
  46349. * @param onProgress The callback when the load progresses
  46350. * @param fileName Defines the name of the file to load
  46351. * @returns Nothing
  46352. */
  46353. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  46354. /**
  46355. * Load into an asset container.
  46356. * @param scene The scene to load into
  46357. * @param data The data to import
  46358. * @param rootUrl The root url for scene and resources
  46359. * @param onProgress The callback when the load progresses
  46360. * @param fileName Defines the name of the file to load
  46361. * @returns The loaded asset container
  46362. */
  46363. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  46364. }
  46365. /**
  46366. * Mode that determines how to handle old animation groups before loading new ones.
  46367. */
  46368. export enum SceneLoaderAnimationGroupLoadingMode {
  46369. /**
  46370. * Reset all old animations to initial state then dispose them.
  46371. */
  46372. Clean = 0,
  46373. /**
  46374. * Stop all old animations.
  46375. */
  46376. Stop = 1,
  46377. /**
  46378. * Restart old animations from first frame.
  46379. */
  46380. Sync = 2,
  46381. /**
  46382. * Old animations remains untouched.
  46383. */
  46384. NoSync = 3
  46385. }
  46386. /**
  46387. * Class used to load scene from various file formats using registered plugins
  46388. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  46389. */
  46390. export class SceneLoader {
  46391. /**
  46392. * No logging while loading
  46393. */
  46394. static readonly NO_LOGGING: number;
  46395. /**
  46396. * Minimal logging while loading
  46397. */
  46398. static readonly MINIMAL_LOGGING: number;
  46399. /**
  46400. * Summary logging while loading
  46401. */
  46402. static readonly SUMMARY_LOGGING: number;
  46403. /**
  46404. * Detailled logging while loading
  46405. */
  46406. static readonly DETAILED_LOGGING: number;
  46407. /**
  46408. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  46409. */
  46410. static get ForceFullSceneLoadingForIncremental(): boolean;
  46411. static set ForceFullSceneLoadingForIncremental(value: boolean);
  46412. /**
  46413. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  46414. */
  46415. static get ShowLoadingScreen(): boolean;
  46416. static set ShowLoadingScreen(value: boolean);
  46417. /**
  46418. * Defines the current logging level (while loading the scene)
  46419. * @ignorenaming
  46420. */
  46421. static get loggingLevel(): number;
  46422. static set loggingLevel(value: number);
  46423. /**
  46424. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  46425. */
  46426. static get CleanBoneMatrixWeights(): boolean;
  46427. static set CleanBoneMatrixWeights(value: boolean);
  46428. /**
  46429. * Event raised when a plugin is used to load a scene
  46430. */
  46431. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  46432. private static _registeredPlugins;
  46433. private static _getDefaultPlugin;
  46434. private static _getPluginForExtension;
  46435. private static _getPluginForDirectLoad;
  46436. private static _getPluginForFilename;
  46437. private static _getDirectLoad;
  46438. private static _loadData;
  46439. private static _getFileInfo;
  46440. /**
  46441. * Gets a plugin that can load the given extension
  46442. * @param extension defines the extension to load
  46443. * @returns a plugin or null if none works
  46444. */
  46445. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  46446. /**
  46447. * Gets a boolean indicating that the given extension can be loaded
  46448. * @param extension defines the extension to load
  46449. * @returns true if the extension is supported
  46450. */
  46451. static IsPluginForExtensionAvailable(extension: string): boolean;
  46452. /**
  46453. * Adds a new plugin to the list of registered plugins
  46454. * @param plugin defines the plugin to add
  46455. */
  46456. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  46457. /**
  46458. * Import meshes into a scene
  46459. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46460. * @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)
  46461. * @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)
  46462. * @param scene the instance of BABYLON.Scene to append to
  46463. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  46464. * @param onProgress a callback with a progress event for each file being loaded
  46465. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46466. * @param pluginExtension the extension used to determine the plugin
  46467. * @returns The loaded plugin
  46468. */
  46469. 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>;
  46470. /**
  46471. * Import meshes into a scene
  46472. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46473. * @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)
  46474. * @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)
  46475. * @param scene the instance of BABYLON.Scene to append to
  46476. * @param onProgress a callback with a progress event for each file being loaded
  46477. * @param pluginExtension the extension used to determine the plugin
  46478. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  46479. */
  46480. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  46481. meshes: AbstractMesh[];
  46482. particleSystems: IParticleSystem[];
  46483. skeletons: Skeleton[];
  46484. animationGroups: AnimationGroup[];
  46485. }>;
  46486. /**
  46487. * Load a scene
  46488. * @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)
  46489. * @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)
  46490. * @param engine is the instance of BABYLON.Engine to use to create the scene
  46491. * @param onSuccess a callback with the scene when import succeeds
  46492. * @param onProgress a callback with a progress event for each file being loaded
  46493. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46494. * @param pluginExtension the extension used to determine the plugin
  46495. * @returns The loaded plugin
  46496. */
  46497. 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>;
  46498. /**
  46499. * Load a scene
  46500. * @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)
  46501. * @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)
  46502. * @param engine is the instance of BABYLON.Engine to use to create the scene
  46503. * @param onProgress a callback with a progress event for each file being loaded
  46504. * @param pluginExtension the extension used to determine the plugin
  46505. * @returns The loaded scene
  46506. */
  46507. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  46508. /**
  46509. * Append a scene
  46510. * @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)
  46511. * @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)
  46512. * @param scene is the instance of BABYLON.Scene to append to
  46513. * @param onSuccess a callback with the scene when import succeeds
  46514. * @param onProgress a callback with a progress event for each file being loaded
  46515. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46516. * @param pluginExtension the extension used to determine the plugin
  46517. * @returns The loaded plugin
  46518. */
  46519. 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>;
  46520. /**
  46521. * Append a scene
  46522. * @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)
  46523. * @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)
  46524. * @param scene is the instance of BABYLON.Scene to append to
  46525. * @param onProgress a callback with a progress event for each file being loaded
  46526. * @param pluginExtension the extension used to determine the plugin
  46527. * @returns The given scene
  46528. */
  46529. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  46530. /**
  46531. * Load a scene into an asset container
  46532. * @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)
  46533. * @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)
  46534. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46535. * @param onSuccess a callback with the scene when import succeeds
  46536. * @param onProgress a callback with a progress event for each file being loaded
  46537. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46538. * @param pluginExtension the extension used to determine the plugin
  46539. * @returns The loaded plugin
  46540. */
  46541. 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>;
  46542. /**
  46543. * Load a scene into an asset container
  46544. * @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)
  46545. * @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)
  46546. * @param scene is the instance of Scene to append to
  46547. * @param onProgress a callback with a progress event for each file being loaded
  46548. * @param pluginExtension the extension used to determine the plugin
  46549. * @returns The loaded asset container
  46550. */
  46551. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  46552. /**
  46553. * Import animations from a file into a scene
  46554. * @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)
  46555. * @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)
  46556. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46557. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  46558. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  46559. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  46560. * @param onSuccess a callback with the scene when import succeeds
  46561. * @param onProgress a callback with a progress event for each file being loaded
  46562. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46563. */
  46564. 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;
  46565. /**
  46566. * Import animations from a file into a scene
  46567. * @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)
  46568. * @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)
  46569. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46570. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  46571. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  46572. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  46573. * @param onSuccess a callback with the scene when import succeeds
  46574. * @param onProgress a callback with a progress event for each file being loaded
  46575. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46576. * @returns the updated scene with imported animations
  46577. */
  46578. 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>;
  46579. }
  46580. }
  46581. declare module BABYLON {
  46582. /**
  46583. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  46584. */
  46585. export type MotionControllerHandedness = "none" | "left" | "right";
  46586. /**
  46587. * The type of components available in motion controllers.
  46588. * This is not the name of the component.
  46589. */
  46590. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  46591. /**
  46592. * The state of a controller component
  46593. */
  46594. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  46595. /**
  46596. * The schema of motion controller layout.
  46597. * No object will be initialized using this interface
  46598. * This is used just to define the profile.
  46599. */
  46600. export interface IMotionControllerLayout {
  46601. /**
  46602. * Path to load the assets. Usually relative to the base path
  46603. */
  46604. assetPath: string;
  46605. /**
  46606. * Available components (unsorted)
  46607. */
  46608. components: {
  46609. /**
  46610. * A map of component Ids
  46611. */
  46612. [componentId: string]: {
  46613. /**
  46614. * The type of input the component outputs
  46615. */
  46616. type: MotionControllerComponentType;
  46617. /**
  46618. * The indices of this component in the gamepad object
  46619. */
  46620. gamepadIndices: {
  46621. /**
  46622. * Index of button
  46623. */
  46624. button?: number;
  46625. /**
  46626. * If available, index of x-axis
  46627. */
  46628. xAxis?: number;
  46629. /**
  46630. * If available, index of y-axis
  46631. */
  46632. yAxis?: number;
  46633. };
  46634. /**
  46635. * The mesh's root node name
  46636. */
  46637. rootNodeName: string;
  46638. /**
  46639. * Animation definitions for this model
  46640. */
  46641. visualResponses: {
  46642. [stateKey: string]: {
  46643. /**
  46644. * What property will be animated
  46645. */
  46646. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  46647. /**
  46648. * What states influence this visual response
  46649. */
  46650. states: MotionControllerComponentStateType[];
  46651. /**
  46652. * Type of animation - movement or visibility
  46653. */
  46654. valueNodeProperty: "transform" | "visibility";
  46655. /**
  46656. * Base node name to move. Its position will be calculated according to the min and max nodes
  46657. */
  46658. valueNodeName?: string;
  46659. /**
  46660. * Minimum movement node
  46661. */
  46662. minNodeName?: string;
  46663. /**
  46664. * Max movement node
  46665. */
  46666. maxNodeName?: string;
  46667. };
  46668. };
  46669. /**
  46670. * If touch enabled, what is the name of node to display user feedback
  46671. */
  46672. touchPointNodeName?: string;
  46673. };
  46674. };
  46675. /**
  46676. * Is it xr standard mapping or not
  46677. */
  46678. gamepadMapping: "" | "xr-standard";
  46679. /**
  46680. * Base root node of this entire model
  46681. */
  46682. rootNodeName: string;
  46683. /**
  46684. * Defines the main button component id
  46685. */
  46686. selectComponentId: string;
  46687. }
  46688. /**
  46689. * A definition for the layout map in the input profile
  46690. */
  46691. export interface IMotionControllerLayoutMap {
  46692. /**
  46693. * Layouts with handedness type as a key
  46694. */
  46695. [handedness: string]: IMotionControllerLayout;
  46696. }
  46697. /**
  46698. * The XR Input profile schema
  46699. * Profiles can be found here:
  46700. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  46701. */
  46702. export interface IMotionControllerProfile {
  46703. /**
  46704. * fallback profiles for this profileId
  46705. */
  46706. fallbackProfileIds: string[];
  46707. /**
  46708. * The layout map, with handedness as key
  46709. */
  46710. layouts: IMotionControllerLayoutMap;
  46711. /**
  46712. * The id of this profile
  46713. * correlates to the profile(s) in the xrInput.profiles array
  46714. */
  46715. profileId: string;
  46716. }
  46717. /**
  46718. * A helper-interface for the 3 meshes needed for controller button animation
  46719. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  46720. */
  46721. export interface IMotionControllerButtonMeshMap {
  46722. /**
  46723. * the mesh that defines the pressed value mesh position.
  46724. * This is used to find the max-position of this button
  46725. */
  46726. pressedMesh: AbstractMesh;
  46727. /**
  46728. * the mesh that defines the unpressed value mesh position.
  46729. * This is used to find the min (or initial) position of this button
  46730. */
  46731. unpressedMesh: AbstractMesh;
  46732. /**
  46733. * The mesh that will be changed when value changes
  46734. */
  46735. valueMesh: AbstractMesh;
  46736. }
  46737. /**
  46738. * A helper-interface for the 3 meshes needed for controller axis animation.
  46739. * This will be expanded when touchpad animations are fully supported
  46740. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  46741. */
  46742. export interface IMotionControllerMeshMap {
  46743. /**
  46744. * the mesh that defines the maximum value mesh position.
  46745. */
  46746. maxMesh?: AbstractMesh;
  46747. /**
  46748. * the mesh that defines the minimum value mesh position.
  46749. */
  46750. minMesh?: AbstractMesh;
  46751. /**
  46752. * The mesh that will be changed when axis value changes
  46753. */
  46754. valueMesh: AbstractMesh;
  46755. }
  46756. /**
  46757. * The elements needed for change-detection of the gamepad objects in motion controllers
  46758. */
  46759. export interface IMinimalMotionControllerObject {
  46760. /**
  46761. * Available axes of this controller
  46762. */
  46763. axes: number[];
  46764. /**
  46765. * An array of available buttons
  46766. */
  46767. buttons: Array<{
  46768. /**
  46769. * Value of the button/trigger
  46770. */
  46771. value: number;
  46772. /**
  46773. * If the button/trigger is currently touched
  46774. */
  46775. touched: boolean;
  46776. /**
  46777. * If the button/trigger is currently pressed
  46778. */
  46779. pressed: boolean;
  46780. }>;
  46781. /**
  46782. * EXPERIMENTAL haptic support.
  46783. */
  46784. hapticActuators?: Array<{
  46785. pulse: (value: number, duration: number) => Promise<boolean>;
  46786. }>;
  46787. }
  46788. /**
  46789. * An Abstract Motion controller
  46790. * This class receives an xrInput and a profile layout and uses those to initialize the components
  46791. * Each component has an observable to check for changes in value and state
  46792. */
  46793. export abstract class WebXRAbstractMotionController implements IDisposable {
  46794. protected scene: Scene;
  46795. protected layout: IMotionControllerLayout;
  46796. /**
  46797. * The gamepad object correlating to this controller
  46798. */
  46799. gamepadObject: IMinimalMotionControllerObject;
  46800. /**
  46801. * handedness (left/right/none) of this controller
  46802. */
  46803. handedness: MotionControllerHandedness;
  46804. private _initComponent;
  46805. private _modelReady;
  46806. /**
  46807. * A map of components (WebXRControllerComponent) in this motion controller
  46808. * Components have a ComponentType and can also have both button and axis definitions
  46809. */
  46810. readonly components: {
  46811. [id: string]: WebXRControllerComponent;
  46812. };
  46813. /**
  46814. * Disable the model's animation. Can be set at any time.
  46815. */
  46816. disableAnimation: boolean;
  46817. /**
  46818. * Observers registered here will be triggered when the model of this controller is done loading
  46819. */
  46820. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  46821. /**
  46822. * The profile id of this motion controller
  46823. */
  46824. abstract profileId: string;
  46825. /**
  46826. * The root mesh of the model. It is null if the model was not yet initialized
  46827. */
  46828. rootMesh: Nullable<AbstractMesh>;
  46829. /**
  46830. * constructs a new abstract motion controller
  46831. * @param scene the scene to which the model of the controller will be added
  46832. * @param layout The profile layout to load
  46833. * @param gamepadObject The gamepad object correlating to this controller
  46834. * @param handedness handedness (left/right/none) of this controller
  46835. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  46836. */
  46837. constructor(scene: Scene, layout: IMotionControllerLayout,
  46838. /**
  46839. * The gamepad object correlating to this controller
  46840. */
  46841. gamepadObject: IMinimalMotionControllerObject,
  46842. /**
  46843. * handedness (left/right/none) of this controller
  46844. */
  46845. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  46846. /**
  46847. * Dispose this controller, the model mesh and all its components
  46848. */
  46849. dispose(): void;
  46850. /**
  46851. * Returns all components of specific type
  46852. * @param type the type to search for
  46853. * @return an array of components with this type
  46854. */
  46855. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  46856. /**
  46857. * get a component based an its component id as defined in layout.components
  46858. * @param id the id of the component
  46859. * @returns the component correlates to the id or undefined if not found
  46860. */
  46861. getComponent(id: string): WebXRControllerComponent;
  46862. /**
  46863. * Get the list of components available in this motion controller
  46864. * @returns an array of strings correlating to available components
  46865. */
  46866. getComponentIds(): string[];
  46867. /**
  46868. * Get the first component of specific type
  46869. * @param type type of component to find
  46870. * @return a controller component or null if not found
  46871. */
  46872. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  46873. /**
  46874. * Get the main (Select) component of this controller as defined in the layout
  46875. * @returns the main component of this controller
  46876. */
  46877. getMainComponent(): WebXRControllerComponent;
  46878. /**
  46879. * Loads the model correlating to this controller
  46880. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  46881. * @returns A promise fulfilled with the result of the model loading
  46882. */
  46883. loadModel(): Promise<boolean>;
  46884. /**
  46885. * Update this model using the current XRFrame
  46886. * @param xrFrame the current xr frame to use and update the model
  46887. */
  46888. updateFromXRFrame(xrFrame: XRFrame): void;
  46889. /**
  46890. * Backwards compatibility due to a deeply-integrated typo
  46891. */
  46892. get handness(): XREye;
  46893. /**
  46894. * Pulse (vibrate) this controller
  46895. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  46896. * Consecutive calls to this function will cancel the last pulse call
  46897. *
  46898. * @param value the strength of the pulse in 0.0...1.0 range
  46899. * @param duration Duration of the pulse in milliseconds
  46900. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  46901. * @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
  46902. */
  46903. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  46904. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  46905. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  46906. /**
  46907. * Moves the axis on the controller mesh based on its current state
  46908. * @param axis the index of the axis
  46909. * @param axisValue the value of the axis which determines the meshes new position
  46910. * @hidden
  46911. */
  46912. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  46913. /**
  46914. * Update the model itself with the current frame data
  46915. * @param xrFrame the frame to use for updating the model mesh
  46916. */
  46917. protected updateModel(xrFrame: XRFrame): void;
  46918. /**
  46919. * Get the filename and path for this controller's model
  46920. * @returns a map of filename and path
  46921. */
  46922. protected abstract _getFilenameAndPath(): {
  46923. filename: string;
  46924. path: string;
  46925. };
  46926. /**
  46927. * This function is called before the mesh is loaded. It checks for loading constraints.
  46928. * For example, this function can check if the GLB loader is available
  46929. * If this function returns false, the generic controller will be loaded instead
  46930. * @returns Is the client ready to load the mesh
  46931. */
  46932. protected abstract _getModelLoadingConstraints(): boolean;
  46933. /**
  46934. * This function will be called after the model was successfully loaded and can be used
  46935. * for mesh transformations before it is available for the user
  46936. * @param meshes the loaded meshes
  46937. */
  46938. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  46939. /**
  46940. * Set the root mesh for this controller. Important for the WebXR controller class
  46941. * @param meshes the loaded meshes
  46942. */
  46943. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  46944. /**
  46945. * A function executed each frame that updates the mesh (if needed)
  46946. * @param xrFrame the current xrFrame
  46947. */
  46948. protected abstract _updateModel(xrFrame: XRFrame): void;
  46949. private _getGenericFilenameAndPath;
  46950. private _getGenericParentMesh;
  46951. }
  46952. }
  46953. declare module BABYLON {
  46954. /**
  46955. * A generic trigger-only motion controller for WebXR
  46956. */
  46957. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  46958. /**
  46959. * Static version of the profile id of this controller
  46960. */
  46961. static ProfileId: string;
  46962. profileId: string;
  46963. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  46964. protected _getFilenameAndPath(): {
  46965. filename: string;
  46966. path: string;
  46967. };
  46968. protected _getModelLoadingConstraints(): boolean;
  46969. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  46970. protected _setRootMesh(meshes: AbstractMesh[]): void;
  46971. protected _updateModel(): void;
  46972. }
  46973. }
  46974. declare module BABYLON {
  46975. /**
  46976. * Class containing static functions to help procedurally build meshes
  46977. */
  46978. export class SphereBuilder {
  46979. /**
  46980. * Creates a sphere mesh
  46981. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  46982. * * 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`)
  46983. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  46984. * * 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
  46985. * * 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)
  46986. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46987. * * 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
  46988. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46989. * @param name defines the name of the mesh
  46990. * @param options defines the options used to create the mesh
  46991. * @param scene defines the hosting scene
  46992. * @returns the sphere mesh
  46993. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  46994. */
  46995. static CreateSphere(name: string, options: {
  46996. segments?: number;
  46997. diameter?: number;
  46998. diameterX?: number;
  46999. diameterY?: number;
  47000. diameterZ?: number;
  47001. arc?: number;
  47002. slice?: number;
  47003. sideOrientation?: number;
  47004. frontUVs?: Vector4;
  47005. backUVs?: Vector4;
  47006. updatable?: boolean;
  47007. }, scene?: Nullable<Scene>): Mesh;
  47008. }
  47009. }
  47010. declare module BABYLON {
  47011. /**
  47012. * A profiled motion controller has its profile loaded from an online repository.
  47013. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  47014. */
  47015. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  47016. private _repositoryUrl;
  47017. private _buttonMeshMapping;
  47018. private _touchDots;
  47019. /**
  47020. * The profile ID of this controller. Will be populated when the controller initializes.
  47021. */
  47022. profileId: string;
  47023. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  47024. dispose(): void;
  47025. protected _getFilenameAndPath(): {
  47026. filename: string;
  47027. path: string;
  47028. };
  47029. protected _getModelLoadingConstraints(): boolean;
  47030. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  47031. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47032. protected _updateModel(_xrFrame: XRFrame): void;
  47033. }
  47034. }
  47035. declare module BABYLON {
  47036. /**
  47037. * A construction function type to create a new controller based on an xrInput object
  47038. */
  47039. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  47040. /**
  47041. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  47042. *
  47043. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  47044. * it should be replaced with auto-loaded controllers.
  47045. *
  47046. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  47047. */
  47048. export class WebXRMotionControllerManager {
  47049. private static _AvailableControllers;
  47050. private static _Fallbacks;
  47051. private static _ProfileLoadingPromises;
  47052. private static _ProfilesList;
  47053. /**
  47054. * The base URL of the online controller repository. Can be changed at any time.
  47055. */
  47056. static BaseRepositoryUrl: string;
  47057. /**
  47058. * Which repository gets priority - local or online
  47059. */
  47060. static PrioritizeOnlineRepository: boolean;
  47061. /**
  47062. * Use the online repository, or use only locally-defined controllers
  47063. */
  47064. static UseOnlineRepository: boolean;
  47065. /**
  47066. * Clear the cache used for profile loading and reload when requested again
  47067. */
  47068. static ClearProfilesCache(): void;
  47069. /**
  47070. * Register the default fallbacks.
  47071. * This function is called automatically when this file is imported.
  47072. */
  47073. static DefaultFallbacks(): void;
  47074. /**
  47075. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  47076. * @param profileId the profile to which a fallback needs to be found
  47077. * @return an array with corresponding fallback profiles
  47078. */
  47079. static FindFallbackWithProfileId(profileId: string): string[];
  47080. /**
  47081. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  47082. * The order of search:
  47083. *
  47084. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  47085. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  47086. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  47087. * 4) return the generic trigger controller if none were found
  47088. *
  47089. * @param xrInput the xrInput to which a new controller is initialized
  47090. * @param scene the scene to which the model will be added
  47091. * @param forceProfile force a certain profile for this controller
  47092. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  47093. */
  47094. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  47095. /**
  47096. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  47097. *
  47098. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  47099. *
  47100. * @param type the profile type to register
  47101. * @param constructFunction the function to be called when loading this profile
  47102. */
  47103. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  47104. /**
  47105. * Register a fallback to a specific profile.
  47106. * @param profileId the profileId that will receive the fallbacks
  47107. * @param fallbacks A list of fallback profiles
  47108. */
  47109. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  47110. /**
  47111. * Will update the list of profiles available in the repository
  47112. * @return a promise that resolves to a map of profiles available online
  47113. */
  47114. static UpdateProfilesList(): Promise<{
  47115. [profile: string]: string;
  47116. }>;
  47117. private static _LoadProfileFromRepository;
  47118. private static _LoadProfilesFromAvailableControllers;
  47119. }
  47120. }
  47121. declare module BABYLON {
  47122. /**
  47123. * Configuration options for the WebXR controller creation
  47124. */
  47125. export interface IWebXRControllerOptions {
  47126. /**
  47127. * Should the controller mesh be animated when a user interacts with it
  47128. * The pressed buttons / thumbstick and touchpad animations will be disabled
  47129. */
  47130. disableMotionControllerAnimation?: boolean;
  47131. /**
  47132. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  47133. */
  47134. doNotLoadControllerMesh?: boolean;
  47135. /**
  47136. * Force a specific controller type for this controller.
  47137. * This can be used when creating your own profile or when testing different controllers
  47138. */
  47139. forceControllerProfile?: string;
  47140. /**
  47141. * Defines a rendering group ID for meshes that will be loaded.
  47142. * This is for the default controllers only.
  47143. */
  47144. renderingGroupId?: number;
  47145. }
  47146. /**
  47147. * Represents an XR controller
  47148. */
  47149. export class WebXRInputSource {
  47150. private _scene;
  47151. /** The underlying input source for the controller */
  47152. inputSource: XRInputSource;
  47153. private _options;
  47154. private _tmpVector;
  47155. private _uniqueId;
  47156. /**
  47157. * 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
  47158. */
  47159. grip?: AbstractMesh;
  47160. /**
  47161. * If available, this is the gamepad object related to this controller.
  47162. * Using this object it is possible to get click events and trackpad changes of the
  47163. * webxr controller that is currently being used.
  47164. */
  47165. motionController?: WebXRAbstractMotionController;
  47166. /**
  47167. * Event that fires when the controller is removed/disposed.
  47168. * The object provided as event data is this controller, after associated assets were disposed.
  47169. * uniqueId is still available.
  47170. */
  47171. onDisposeObservable: Observable<WebXRInputSource>;
  47172. /**
  47173. * Will be triggered when the mesh associated with the motion controller is done loading.
  47174. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  47175. * A shortened version of controller -> motion controller -> on mesh loaded.
  47176. */
  47177. onMeshLoadedObservable: Observable<AbstractMesh>;
  47178. /**
  47179. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  47180. */
  47181. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  47182. /**
  47183. * Pointer which can be used to select objects or attach a visible laser to
  47184. */
  47185. pointer: AbstractMesh;
  47186. /**
  47187. * Creates the controller
  47188. * @see https://doc.babylonjs.com/how_to/webxr
  47189. * @param _scene the scene which the controller should be associated to
  47190. * @param inputSource the underlying input source for the controller
  47191. * @param _options options for this controller creation
  47192. */
  47193. constructor(_scene: Scene,
  47194. /** The underlying input source for the controller */
  47195. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  47196. /**
  47197. * Get this controllers unique id
  47198. */
  47199. get uniqueId(): string;
  47200. /**
  47201. * Disposes of the object
  47202. */
  47203. dispose(): void;
  47204. /**
  47205. * Gets a world space ray coming from the pointer or grip
  47206. * @param result the resulting ray
  47207. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  47208. */
  47209. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  47210. /**
  47211. * Updates the controller pose based on the given XRFrame
  47212. * @param xrFrame xr frame to update the pose with
  47213. * @param referenceSpace reference space to use
  47214. */
  47215. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  47216. }
  47217. }
  47218. declare module BABYLON {
  47219. /**
  47220. * The schema for initialization options of the XR Input class
  47221. */
  47222. export interface IWebXRInputOptions {
  47223. /**
  47224. * If set to true no model will be automatically loaded
  47225. */
  47226. doNotLoadControllerMeshes?: boolean;
  47227. /**
  47228. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  47229. * If not found, the xr input profile data will be used.
  47230. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  47231. */
  47232. forceInputProfile?: string;
  47233. /**
  47234. * Do not send a request to the controller repository to load the profile.
  47235. *
  47236. * Instead, use the controllers available in babylon itself.
  47237. */
  47238. disableOnlineControllerRepository?: boolean;
  47239. /**
  47240. * A custom URL for the controllers repository
  47241. */
  47242. customControllersRepositoryURL?: string;
  47243. /**
  47244. * Should the controller model's components not move according to the user input
  47245. */
  47246. disableControllerAnimation?: boolean;
  47247. /**
  47248. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  47249. */
  47250. controllerOptions?: IWebXRControllerOptions;
  47251. }
  47252. /**
  47253. * XR input used to track XR inputs such as controllers/rays
  47254. */
  47255. export class WebXRInput implements IDisposable {
  47256. /**
  47257. * the xr session manager for this session
  47258. */
  47259. xrSessionManager: WebXRSessionManager;
  47260. /**
  47261. * the WebXR camera for this session. Mainly used for teleportation
  47262. */
  47263. xrCamera: WebXRCamera;
  47264. private readonly options;
  47265. /**
  47266. * XR controllers being tracked
  47267. */
  47268. controllers: Array<WebXRInputSource>;
  47269. private _frameObserver;
  47270. private _sessionEndedObserver;
  47271. private _sessionInitObserver;
  47272. /**
  47273. * Event when a controller has been connected/added
  47274. */
  47275. onControllerAddedObservable: Observable<WebXRInputSource>;
  47276. /**
  47277. * Event when a controller has been removed/disconnected
  47278. */
  47279. onControllerRemovedObservable: Observable<WebXRInputSource>;
  47280. /**
  47281. * Initializes the WebXRInput
  47282. * @param xrSessionManager the xr session manager for this session
  47283. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  47284. * @param options = initialization options for this xr input
  47285. */
  47286. constructor(
  47287. /**
  47288. * the xr session manager for this session
  47289. */
  47290. xrSessionManager: WebXRSessionManager,
  47291. /**
  47292. * the WebXR camera for this session. Mainly used for teleportation
  47293. */
  47294. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  47295. private _onInputSourcesChange;
  47296. private _addAndRemoveControllers;
  47297. /**
  47298. * Disposes of the object
  47299. */
  47300. dispose(): void;
  47301. }
  47302. }
  47303. declare module BABYLON {
  47304. /**
  47305. * This is the base class for all WebXR features.
  47306. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  47307. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  47308. */
  47309. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  47310. protected _xrSessionManager: WebXRSessionManager;
  47311. private _attached;
  47312. private _removeOnDetach;
  47313. /**
  47314. * Should auto-attach be disabled?
  47315. */
  47316. disableAutoAttach: boolean;
  47317. /**
  47318. * Construct a new (abstract) WebXR feature
  47319. * @param _xrSessionManager the xr session manager for this feature
  47320. */
  47321. constructor(_xrSessionManager: WebXRSessionManager);
  47322. /**
  47323. * Is this feature attached
  47324. */
  47325. get attached(): boolean;
  47326. /**
  47327. * attach this feature
  47328. *
  47329. * @param force should attachment be forced (even when already attached)
  47330. * @returns true if successful, false is failed or already attached
  47331. */
  47332. attach(force?: boolean): boolean;
  47333. /**
  47334. * detach this feature.
  47335. *
  47336. * @returns true if successful, false if failed or already detached
  47337. */
  47338. detach(): boolean;
  47339. /**
  47340. * Dispose this feature and all of the resources attached
  47341. */
  47342. dispose(): void;
  47343. /**
  47344. * This is used to register callbacks that will automatically be removed when detach is called.
  47345. * @param observable the observable to which the observer will be attached
  47346. * @param callback the callback to register
  47347. */
  47348. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  47349. /**
  47350. * Code in this function will be executed on each xrFrame received from the browser.
  47351. * This function will not execute after the feature is detached.
  47352. * @param _xrFrame the current frame
  47353. */
  47354. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  47355. }
  47356. }
  47357. declare module BABYLON {
  47358. /**
  47359. * Renders a layer on top of an existing scene
  47360. */
  47361. export class UtilityLayerRenderer implements IDisposable {
  47362. /** the original scene that will be rendered on top of */
  47363. originalScene: Scene;
  47364. private _pointerCaptures;
  47365. private _lastPointerEvents;
  47366. private static _DefaultUtilityLayer;
  47367. private static _DefaultKeepDepthUtilityLayer;
  47368. private _sharedGizmoLight;
  47369. private _renderCamera;
  47370. /**
  47371. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  47372. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  47373. * @returns the camera that is used when rendering the utility layer
  47374. */
  47375. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  47376. /**
  47377. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  47378. * @param cam the camera that should be used when rendering the utility layer
  47379. */
  47380. setRenderCamera(cam: Nullable<Camera>): void;
  47381. /**
  47382. * @hidden
  47383. * Light which used by gizmos to get light shading
  47384. */
  47385. _getSharedGizmoLight(): HemisphericLight;
  47386. /**
  47387. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  47388. */
  47389. pickUtilitySceneFirst: boolean;
  47390. /**
  47391. * 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)
  47392. */
  47393. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  47394. /**
  47395. * 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)
  47396. */
  47397. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  47398. /**
  47399. * The scene that is rendered on top of the original scene
  47400. */
  47401. utilityLayerScene: Scene;
  47402. /**
  47403. * If the utility layer should automatically be rendered on top of existing scene
  47404. */
  47405. shouldRender: boolean;
  47406. /**
  47407. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  47408. */
  47409. onlyCheckPointerDownEvents: boolean;
  47410. /**
  47411. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  47412. */
  47413. processAllEvents: boolean;
  47414. /**
  47415. * Observable raised when the pointer move from the utility layer scene to the main scene
  47416. */
  47417. onPointerOutObservable: Observable<number>;
  47418. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  47419. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  47420. private _afterRenderObserver;
  47421. private _sceneDisposeObserver;
  47422. private _originalPointerObserver;
  47423. /**
  47424. * Instantiates a UtilityLayerRenderer
  47425. * @param originalScene the original scene that will be rendered on top of
  47426. * @param handleEvents boolean indicating if the utility layer should handle events
  47427. */
  47428. constructor(
  47429. /** the original scene that will be rendered on top of */
  47430. originalScene: Scene, handleEvents?: boolean);
  47431. private _notifyObservers;
  47432. /**
  47433. * Renders the utility layers scene on top of the original scene
  47434. */
  47435. render(): void;
  47436. /**
  47437. * Disposes of the renderer
  47438. */
  47439. dispose(): void;
  47440. private _updateCamera;
  47441. }
  47442. }
  47443. declare module BABYLON {
  47444. /**
  47445. * Options interface for the pointer selection module
  47446. */
  47447. export interface IWebXRControllerPointerSelectionOptions {
  47448. /**
  47449. * if provided, this scene will be used to render meshes.
  47450. */
  47451. customUtilityLayerScene?: Scene;
  47452. /**
  47453. * 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)
  47454. * If not disabled, the last picked point will be used to execute a pointer up event
  47455. * If disabled, pointer up event will be triggered right after the pointer down event.
  47456. * Used in screen and gaze target ray mode only
  47457. */
  47458. disablePointerUpOnTouchOut: boolean;
  47459. /**
  47460. * For gaze mode (time to select instead of press)
  47461. */
  47462. forceGazeMode: boolean;
  47463. /**
  47464. * 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
  47465. * to start a new countdown to the pointer down event.
  47466. * Defaults to 1.
  47467. */
  47468. gazeModePointerMovedFactor?: number;
  47469. /**
  47470. * Different button type to use instead of the main component
  47471. */
  47472. overrideButtonId?: string;
  47473. /**
  47474. * use this rendering group id for the meshes (optional)
  47475. */
  47476. renderingGroupId?: number;
  47477. /**
  47478. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  47479. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  47480. * 3000 means 3 seconds between pointing at something and selecting it
  47481. */
  47482. timeToSelect?: number;
  47483. /**
  47484. * Should meshes created here be added to a utility layer or the main scene
  47485. */
  47486. useUtilityLayer?: boolean;
  47487. /**
  47488. * the xr input to use with this pointer selection
  47489. */
  47490. xrInput: WebXRInput;
  47491. }
  47492. /**
  47493. * A module that will enable pointer selection for motion controllers of XR Input Sources
  47494. */
  47495. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  47496. private readonly _options;
  47497. private static _idCounter;
  47498. private _attachController;
  47499. private _controllers;
  47500. private _scene;
  47501. private _tmpVectorForPickCompare;
  47502. /**
  47503. * The module's name
  47504. */
  47505. static readonly Name: string;
  47506. /**
  47507. * The (Babylon) version of this module.
  47508. * This is an integer representing the implementation version.
  47509. * This number does not correspond to the WebXR specs version
  47510. */
  47511. static readonly Version: number;
  47512. /**
  47513. * Disable lighting on the laser pointer (so it will always be visible)
  47514. */
  47515. disablePointerLighting: boolean;
  47516. /**
  47517. * Disable lighting on the selection mesh (so it will always be visible)
  47518. */
  47519. disableSelectionMeshLighting: boolean;
  47520. /**
  47521. * Should the laser pointer be displayed
  47522. */
  47523. displayLaserPointer: boolean;
  47524. /**
  47525. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  47526. */
  47527. displaySelectionMesh: boolean;
  47528. /**
  47529. * This color will be set to the laser pointer when selection is triggered
  47530. */
  47531. laserPointerPickedColor: Color3;
  47532. /**
  47533. * Default color of the laser pointer
  47534. */
  47535. lasterPointerDefaultColor: Color3;
  47536. /**
  47537. * default color of the selection ring
  47538. */
  47539. selectionMeshDefaultColor: Color3;
  47540. /**
  47541. * This color will be applied to the selection ring when selection is triggered
  47542. */
  47543. selectionMeshPickedColor: Color3;
  47544. /**
  47545. * Optional filter to be used for ray selection. This predicate shares behavior with
  47546. * scene.pointerMovePredicate which takes priority if it is also assigned.
  47547. */
  47548. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  47549. /**
  47550. * constructs a new background remover module
  47551. * @param _xrSessionManager the session manager for this module
  47552. * @param _options read-only options to be used in this module
  47553. */
  47554. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  47555. /**
  47556. * attach this feature
  47557. * Will usually be called by the features manager
  47558. *
  47559. * @returns true if successful.
  47560. */
  47561. attach(): boolean;
  47562. /**
  47563. * detach this feature.
  47564. * Will usually be called by the features manager
  47565. *
  47566. * @returns true if successful.
  47567. */
  47568. detach(): boolean;
  47569. /**
  47570. * Will get the mesh under a specific pointer.
  47571. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  47572. * @param controllerId the controllerId to check
  47573. * @returns The mesh under pointer or null if no mesh is under the pointer
  47574. */
  47575. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  47576. /**
  47577. * Get the xr controller that correlates to the pointer id in the pointer event
  47578. *
  47579. * @param id the pointer id to search for
  47580. * @returns the controller that correlates to this id or null if not found
  47581. */
  47582. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  47583. protected _onXRFrame(_xrFrame: XRFrame): void;
  47584. private _attachGazeMode;
  47585. private _attachScreenRayMode;
  47586. private _attachTrackedPointerRayMode;
  47587. private _convertNormalToDirectionOfRay;
  47588. private _detachController;
  47589. private _generateNewMeshPair;
  47590. private _pickingMoved;
  47591. private _updatePointerDistance;
  47592. }
  47593. }
  47594. declare module BABYLON {
  47595. /**
  47596. * Button which can be used to enter a different mode of XR
  47597. */
  47598. export class WebXREnterExitUIButton {
  47599. /** button element */
  47600. element: HTMLElement;
  47601. /** XR initialization options for the button */
  47602. sessionMode: XRSessionMode;
  47603. /** Reference space type */
  47604. referenceSpaceType: XRReferenceSpaceType;
  47605. /**
  47606. * Creates a WebXREnterExitUIButton
  47607. * @param element button element
  47608. * @param sessionMode XR initialization session mode
  47609. * @param referenceSpaceType the type of reference space to be used
  47610. */
  47611. constructor(
  47612. /** button element */
  47613. element: HTMLElement,
  47614. /** XR initialization options for the button */
  47615. sessionMode: XRSessionMode,
  47616. /** Reference space type */
  47617. referenceSpaceType: XRReferenceSpaceType);
  47618. /**
  47619. * Extendable function which can be used to update the button's visuals when the state changes
  47620. * @param activeButton the current active button in the UI
  47621. */
  47622. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  47623. }
  47624. /**
  47625. * Options to create the webXR UI
  47626. */
  47627. export class WebXREnterExitUIOptions {
  47628. /**
  47629. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  47630. */
  47631. customButtons?: Array<WebXREnterExitUIButton>;
  47632. /**
  47633. * A reference space type to use when creating the default button.
  47634. * Default is local-floor
  47635. */
  47636. referenceSpaceType?: XRReferenceSpaceType;
  47637. /**
  47638. * Context to enter xr with
  47639. */
  47640. renderTarget?: Nullable<WebXRRenderTarget>;
  47641. /**
  47642. * A session mode to use when creating the default button.
  47643. * Default is immersive-vr
  47644. */
  47645. sessionMode?: XRSessionMode;
  47646. /**
  47647. * A list of optional features to init the session with
  47648. */
  47649. optionalFeatures?: string[];
  47650. }
  47651. /**
  47652. * UI to allow the user to enter/exit XR mode
  47653. */
  47654. export class WebXREnterExitUI implements IDisposable {
  47655. private scene;
  47656. /** version of the options passed to this UI */
  47657. options: WebXREnterExitUIOptions;
  47658. private _activeButton;
  47659. private _buttons;
  47660. private _overlay;
  47661. /**
  47662. * Fired every time the active button is changed.
  47663. *
  47664. * When xr is entered via a button that launches xr that button will be the callback parameter
  47665. *
  47666. * When exiting xr the callback parameter will be null)
  47667. */
  47668. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  47669. /**
  47670. *
  47671. * @param scene babylon scene object to use
  47672. * @param options (read-only) version of the options passed to this UI
  47673. */
  47674. private constructor();
  47675. /**
  47676. * Creates UI to allow the user to enter/exit XR mode
  47677. * @param scene the scene to add the ui to
  47678. * @param helper the xr experience helper to enter/exit xr with
  47679. * @param options options to configure the UI
  47680. * @returns the created ui
  47681. */
  47682. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  47683. /**
  47684. * Disposes of the XR UI component
  47685. */
  47686. dispose(): void;
  47687. private _updateButtons;
  47688. }
  47689. }
  47690. declare module BABYLON {
  47691. /**
  47692. * Class containing static functions to help procedurally build meshes
  47693. */
  47694. export class LinesBuilder {
  47695. /**
  47696. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  47697. * * 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
  47698. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  47699. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  47700. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  47701. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  47702. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  47703. * * 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
  47704. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  47705. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47706. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  47707. * @param name defines the name of the new line system
  47708. * @param options defines the options used to create the line system
  47709. * @param scene defines the hosting scene
  47710. * @returns a new line system mesh
  47711. */
  47712. static CreateLineSystem(name: string, options: {
  47713. lines: Vector3[][];
  47714. updatable?: boolean;
  47715. instance?: Nullable<LinesMesh>;
  47716. colors?: Nullable<Color4[][]>;
  47717. useVertexAlpha?: boolean;
  47718. }, scene: Nullable<Scene>): LinesMesh;
  47719. /**
  47720. * Creates a line mesh
  47721. * 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
  47722. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47723. * * The parameter `points` is an array successive Vector3
  47724. * * 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
  47725. * * The optional parameter `colors` is an array of successive Color4, one per line point
  47726. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  47727. * * When updating an instance, remember that only point positions can change, not the number of points
  47728. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47729. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  47730. * @param name defines the name of the new line system
  47731. * @param options defines the options used to create the line system
  47732. * @param scene defines the hosting scene
  47733. * @returns a new line mesh
  47734. */
  47735. static CreateLines(name: string, options: {
  47736. points: Vector3[];
  47737. updatable?: boolean;
  47738. instance?: Nullable<LinesMesh>;
  47739. colors?: Color4[];
  47740. useVertexAlpha?: boolean;
  47741. }, scene?: Nullable<Scene>): LinesMesh;
  47742. /**
  47743. * Creates a dashed line mesh
  47744. * * 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
  47745. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47746. * * The parameter `points` is an array successive Vector3
  47747. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  47748. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  47749. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  47750. * * 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
  47751. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  47752. * * When updating an instance, remember that only point positions can change, not the number of points
  47753. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47754. * @param name defines the name of the mesh
  47755. * @param options defines the options used to create the mesh
  47756. * @param scene defines the hosting scene
  47757. * @returns the dashed line mesh
  47758. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  47759. */
  47760. static CreateDashedLines(name: string, options: {
  47761. points: Vector3[];
  47762. dashSize?: number;
  47763. gapSize?: number;
  47764. dashNb?: number;
  47765. updatable?: boolean;
  47766. instance?: LinesMesh;
  47767. useVertexAlpha?: boolean;
  47768. }, scene?: Nullable<Scene>): LinesMesh;
  47769. }
  47770. }
  47771. declare module BABYLON {
  47772. /**
  47773. * The options container for the teleportation module
  47774. */
  47775. export interface IWebXRTeleportationOptions {
  47776. /**
  47777. * if provided, this scene will be used to render meshes.
  47778. */
  47779. customUtilityLayerScene?: Scene;
  47780. /**
  47781. * Values to configure the default target mesh
  47782. */
  47783. defaultTargetMeshOptions?: {
  47784. /**
  47785. * Fill color of the teleportation area
  47786. */
  47787. teleportationFillColor?: string;
  47788. /**
  47789. * Border color for the teleportation area
  47790. */
  47791. teleportationBorderColor?: string;
  47792. /**
  47793. * Disable the mesh's animation sequence
  47794. */
  47795. disableAnimation?: boolean;
  47796. /**
  47797. * Disable lighting on the material or the ring and arrow
  47798. */
  47799. disableLighting?: boolean;
  47800. /**
  47801. * Override the default material of the torus and arrow
  47802. */
  47803. torusArrowMaterial?: Material;
  47804. };
  47805. /**
  47806. * A list of meshes to use as floor meshes.
  47807. * Meshes can be added and removed after initializing the feature using the
  47808. * addFloorMesh and removeFloorMesh functions
  47809. * If empty, rotation will still work
  47810. */
  47811. floorMeshes?: AbstractMesh[];
  47812. /**
  47813. * use this rendering group id for the meshes (optional)
  47814. */
  47815. renderingGroupId?: number;
  47816. /**
  47817. * Should teleportation move only to snap points
  47818. */
  47819. snapPointsOnly?: boolean;
  47820. /**
  47821. * An array of points to which the teleportation will snap to.
  47822. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  47823. */
  47824. snapPositions?: Vector3[];
  47825. /**
  47826. * How close should the teleportation ray be in order to snap to position.
  47827. * Default to 0.8 units (meters)
  47828. */
  47829. snapToPositionRadius?: number;
  47830. /**
  47831. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  47832. * If you want to support rotation, make sure your mesh has a direction indicator.
  47833. *
  47834. * When left untouched, the default mesh will be initialized.
  47835. */
  47836. teleportationTargetMesh?: AbstractMesh;
  47837. /**
  47838. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  47839. */
  47840. timeToTeleport?: number;
  47841. /**
  47842. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  47843. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  47844. */
  47845. useMainComponentOnly?: boolean;
  47846. /**
  47847. * Should meshes created here be added to a utility layer or the main scene
  47848. */
  47849. useUtilityLayer?: boolean;
  47850. /**
  47851. * Babylon XR Input class for controller
  47852. */
  47853. xrInput: WebXRInput;
  47854. }
  47855. /**
  47856. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  47857. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  47858. * the input of the attached controllers.
  47859. */
  47860. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  47861. private _options;
  47862. private _controllers;
  47863. private _currentTeleportationControllerId;
  47864. private _floorMeshes;
  47865. private _quadraticBezierCurve;
  47866. private _selectionFeature;
  47867. private _snapToPositions;
  47868. private _snappedToPoint;
  47869. private _teleportationRingMaterial?;
  47870. private _tmpRay;
  47871. private _tmpVector;
  47872. /**
  47873. * The module's name
  47874. */
  47875. static readonly Name: string;
  47876. /**
  47877. * The (Babylon) version of this module.
  47878. * This is an integer representing the implementation version.
  47879. * This number does not correspond to the webxr specs version
  47880. */
  47881. static readonly Version: number;
  47882. /**
  47883. * Is movement backwards enabled
  47884. */
  47885. backwardsMovementEnabled: boolean;
  47886. /**
  47887. * Distance to travel when moving backwards
  47888. */
  47889. backwardsTeleportationDistance: number;
  47890. /**
  47891. * The distance from the user to the inspection point in the direction of the controller
  47892. * A higher number will allow the user to move further
  47893. * defaults to 5 (meters, in xr units)
  47894. */
  47895. parabolicCheckRadius: number;
  47896. /**
  47897. * Should the module support parabolic ray on top of direct ray
  47898. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  47899. * Very helpful when moving between floors / different heights
  47900. */
  47901. parabolicRayEnabled: boolean;
  47902. /**
  47903. * How much rotation should be applied when rotating right and left
  47904. */
  47905. rotationAngle: number;
  47906. /**
  47907. * Is rotation enabled when moving forward?
  47908. * Disabling this feature will prevent the user from deciding the direction when teleporting
  47909. */
  47910. rotationEnabled: boolean;
  47911. /**
  47912. * constructs a new anchor system
  47913. * @param _xrSessionManager an instance of WebXRSessionManager
  47914. * @param _options configuration object for this feature
  47915. */
  47916. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  47917. /**
  47918. * Get the snapPointsOnly flag
  47919. */
  47920. get snapPointsOnly(): boolean;
  47921. /**
  47922. * Sets the snapPointsOnly flag
  47923. * @param snapToPoints should teleportation be exclusively to snap points
  47924. */
  47925. set snapPointsOnly(snapToPoints: boolean);
  47926. /**
  47927. * Add a new mesh to the floor meshes array
  47928. * @param mesh the mesh to use as floor mesh
  47929. */
  47930. addFloorMesh(mesh: AbstractMesh): void;
  47931. /**
  47932. * Add a new snap-to point to fix teleportation to this position
  47933. * @param newSnapPoint The new Snap-To point
  47934. */
  47935. addSnapPoint(newSnapPoint: Vector3): void;
  47936. attach(): boolean;
  47937. detach(): boolean;
  47938. dispose(): void;
  47939. /**
  47940. * Remove a mesh from the floor meshes array
  47941. * @param mesh the mesh to remove
  47942. */
  47943. removeFloorMesh(mesh: AbstractMesh): void;
  47944. /**
  47945. * Remove a mesh from the floor meshes array using its name
  47946. * @param name the mesh name to remove
  47947. */
  47948. removeFloorMeshByName(name: string): void;
  47949. /**
  47950. * 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
  47951. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  47952. * @returns was the point found and removed or not
  47953. */
  47954. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  47955. /**
  47956. * This function sets a selection feature that will be disabled when
  47957. * the forward ray is shown and will be reattached when hidden.
  47958. * This is used to remove the selection rays when moving.
  47959. * @param selectionFeature the feature to disable when forward movement is enabled
  47960. */
  47961. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  47962. protected _onXRFrame(_xrFrame: XRFrame): void;
  47963. private _attachController;
  47964. private _createDefaultTargetMesh;
  47965. private _detachController;
  47966. private _findClosestSnapPointWithRadius;
  47967. private _setTargetMeshPosition;
  47968. private _setTargetMeshVisibility;
  47969. private _showParabolicPath;
  47970. private _teleportForward;
  47971. }
  47972. }
  47973. declare module BABYLON {
  47974. /**
  47975. * Options for the default xr helper
  47976. */
  47977. export class WebXRDefaultExperienceOptions {
  47978. /**
  47979. * Enable or disable default UI to enter XR
  47980. */
  47981. disableDefaultUI?: boolean;
  47982. /**
  47983. * Should teleportation not initialize. defaults to false.
  47984. */
  47985. disableTeleportation?: boolean;
  47986. /**
  47987. * Floor meshes that will be used for teleport
  47988. */
  47989. floorMeshes?: Array<AbstractMesh>;
  47990. /**
  47991. * If set to true, the first frame will not be used to reset position
  47992. * The first frame is mainly used when copying transformation from the old camera
  47993. * Mainly used in AR
  47994. */
  47995. ignoreNativeCameraTransformation?: boolean;
  47996. /**
  47997. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  47998. */
  47999. inputOptions?: IWebXRInputOptions;
  48000. /**
  48001. * optional configuration for the output canvas
  48002. */
  48003. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  48004. /**
  48005. * optional UI options. This can be used among other to change session mode and reference space type
  48006. */
  48007. uiOptions?: WebXREnterExitUIOptions;
  48008. /**
  48009. * When loading teleportation and pointer select, use stable versions instead of latest.
  48010. */
  48011. useStablePlugins?: boolean;
  48012. /**
  48013. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  48014. */
  48015. renderingGroupId?: number;
  48016. /**
  48017. * A list of optional features to init the session with
  48018. * If set to true, all features we support will be added
  48019. */
  48020. optionalFeatures?: boolean | string[];
  48021. }
  48022. /**
  48023. * Default experience which provides a similar setup to the previous webVRExperience
  48024. */
  48025. export class WebXRDefaultExperience {
  48026. /**
  48027. * Base experience
  48028. */
  48029. baseExperience: WebXRExperienceHelper;
  48030. /**
  48031. * Enables ui for entering/exiting xr
  48032. */
  48033. enterExitUI: WebXREnterExitUI;
  48034. /**
  48035. * Input experience extension
  48036. */
  48037. input: WebXRInput;
  48038. /**
  48039. * Enables laser pointer and selection
  48040. */
  48041. pointerSelection: WebXRControllerPointerSelection;
  48042. /**
  48043. * Default target xr should render to
  48044. */
  48045. renderTarget: WebXRRenderTarget;
  48046. /**
  48047. * Enables teleportation
  48048. */
  48049. teleportation: WebXRMotionControllerTeleportation;
  48050. private constructor();
  48051. /**
  48052. * Creates the default xr experience
  48053. * @param scene scene
  48054. * @param options options for basic configuration
  48055. * @returns resulting WebXRDefaultExperience
  48056. */
  48057. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48058. /**
  48059. * DIsposes of the experience helper
  48060. */
  48061. dispose(): void;
  48062. }
  48063. }
  48064. declare module BABYLON {
  48065. /**
  48066. * Options to modify the vr teleportation behavior.
  48067. */
  48068. export interface VRTeleportationOptions {
  48069. /**
  48070. * The name of the mesh which should be used as the teleportation floor. (default: null)
  48071. */
  48072. floorMeshName?: string;
  48073. /**
  48074. * A list of meshes to be used as the teleportation floor. (default: empty)
  48075. */
  48076. floorMeshes?: Mesh[];
  48077. /**
  48078. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  48079. */
  48080. teleportationMode?: number;
  48081. /**
  48082. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  48083. */
  48084. teleportationTime?: number;
  48085. /**
  48086. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  48087. */
  48088. teleportationSpeed?: number;
  48089. /**
  48090. * The easing function used in the animation or null for Linear. (default CircleEase)
  48091. */
  48092. easingFunction?: EasingFunction;
  48093. }
  48094. /**
  48095. * Options to modify the vr experience helper's behavior.
  48096. */
  48097. export interface VRExperienceHelperOptions extends WebVROptions {
  48098. /**
  48099. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  48100. */
  48101. createDeviceOrientationCamera?: boolean;
  48102. /**
  48103. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  48104. */
  48105. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  48106. /**
  48107. * Uses the main button on the controller to toggle the laser casted. (default: true)
  48108. */
  48109. laserToggle?: boolean;
  48110. /**
  48111. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  48112. */
  48113. floorMeshes?: Mesh[];
  48114. /**
  48115. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  48116. */
  48117. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  48118. /**
  48119. * Defines if WebXR should be used instead of WebVR (if available)
  48120. */
  48121. useXR?: boolean;
  48122. }
  48123. /**
  48124. * Event containing information after VR has been entered
  48125. */
  48126. export class OnAfterEnteringVRObservableEvent {
  48127. /**
  48128. * If entering vr was successful
  48129. */
  48130. success: boolean;
  48131. }
  48132. /**
  48133. * Helps to quickly add VR support to an existing scene.
  48134. * See http://doc.babylonjs.com/how_to/webvr_helper
  48135. */
  48136. export class VRExperienceHelper {
  48137. /** Options to modify the vr experience helper's behavior. */
  48138. webVROptions: VRExperienceHelperOptions;
  48139. private _scene;
  48140. private _position;
  48141. private _btnVR;
  48142. private _btnVRDisplayed;
  48143. private _webVRsupported;
  48144. private _webVRready;
  48145. private _webVRrequesting;
  48146. private _webVRpresenting;
  48147. private _hasEnteredVR;
  48148. private _fullscreenVRpresenting;
  48149. private _inputElement;
  48150. private _webVRCamera;
  48151. private _vrDeviceOrientationCamera;
  48152. private _deviceOrientationCamera;
  48153. private _existingCamera;
  48154. private _onKeyDown;
  48155. private _onVrDisplayPresentChange;
  48156. private _onVRDisplayChanged;
  48157. private _onVRRequestPresentStart;
  48158. private _onVRRequestPresentComplete;
  48159. /**
  48160. * 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)
  48161. */
  48162. enableGazeEvenWhenNoPointerLock: boolean;
  48163. /**
  48164. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  48165. */
  48166. exitVROnDoubleTap: boolean;
  48167. /**
  48168. * Observable raised right before entering VR.
  48169. */
  48170. onEnteringVRObservable: Observable<VRExperienceHelper>;
  48171. /**
  48172. * Observable raised when entering VR has completed.
  48173. */
  48174. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  48175. /**
  48176. * Observable raised when exiting VR.
  48177. */
  48178. onExitingVRObservable: Observable<VRExperienceHelper>;
  48179. /**
  48180. * Observable raised when controller mesh is loaded.
  48181. */
  48182. onControllerMeshLoadedObservable: Observable<WebVRController>;
  48183. /** Return this.onEnteringVRObservable
  48184. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  48185. */
  48186. get onEnteringVR(): Observable<VRExperienceHelper>;
  48187. /** Return this.onExitingVRObservable
  48188. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  48189. */
  48190. get onExitingVR(): Observable<VRExperienceHelper>;
  48191. /** Return this.onControllerMeshLoadedObservable
  48192. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  48193. */
  48194. get onControllerMeshLoaded(): Observable<WebVRController>;
  48195. private _rayLength;
  48196. private _useCustomVRButton;
  48197. private _teleportationRequested;
  48198. private _teleportActive;
  48199. private _floorMeshName;
  48200. private _floorMeshesCollection;
  48201. private _teleportationMode;
  48202. private _teleportationTime;
  48203. private _teleportationSpeed;
  48204. private _teleportationEasing;
  48205. private _rotationAllowed;
  48206. private _teleportBackwardsVector;
  48207. private _teleportationTarget;
  48208. private _isDefaultTeleportationTarget;
  48209. private _postProcessMove;
  48210. private _teleportationFillColor;
  48211. private _teleportationBorderColor;
  48212. private _rotationAngle;
  48213. private _haloCenter;
  48214. private _cameraGazer;
  48215. private _padSensibilityUp;
  48216. private _padSensibilityDown;
  48217. private _leftController;
  48218. private _rightController;
  48219. private _gazeColor;
  48220. private _laserColor;
  48221. private _pickedLaserColor;
  48222. private _pickedGazeColor;
  48223. /**
  48224. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  48225. */
  48226. onNewMeshSelected: Observable<AbstractMesh>;
  48227. /**
  48228. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  48229. * This observable will provide the mesh and the controller used to select the mesh
  48230. */
  48231. onMeshSelectedWithController: Observable<{
  48232. mesh: AbstractMesh;
  48233. controller: WebVRController;
  48234. }>;
  48235. /**
  48236. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  48237. */
  48238. onNewMeshPicked: Observable<PickingInfo>;
  48239. private _circleEase;
  48240. /**
  48241. * Observable raised before camera teleportation
  48242. */
  48243. onBeforeCameraTeleport: Observable<Vector3>;
  48244. /**
  48245. * Observable raised after camera teleportation
  48246. */
  48247. onAfterCameraTeleport: Observable<Vector3>;
  48248. /**
  48249. * Observable raised when current selected mesh gets unselected
  48250. */
  48251. onSelectedMeshUnselected: Observable<AbstractMesh>;
  48252. private _raySelectionPredicate;
  48253. /**
  48254. * To be optionaly changed by user to define custom ray selection
  48255. */
  48256. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  48257. /**
  48258. * To be optionaly changed by user to define custom selection logic (after ray selection)
  48259. */
  48260. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48261. /**
  48262. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  48263. */
  48264. teleportationEnabled: boolean;
  48265. private _defaultHeight;
  48266. private _teleportationInitialized;
  48267. private _interactionsEnabled;
  48268. private _interactionsRequested;
  48269. private _displayGaze;
  48270. private _displayLaserPointer;
  48271. /**
  48272. * The mesh used to display where the user is going to teleport.
  48273. */
  48274. get teleportationTarget(): Mesh;
  48275. /**
  48276. * Sets the mesh to be used to display where the user is going to teleport.
  48277. */
  48278. set teleportationTarget(value: Mesh);
  48279. /**
  48280. * 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
  48281. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  48282. * See http://doc.babylonjs.com/resources/baking_transformations
  48283. */
  48284. get gazeTrackerMesh(): Mesh;
  48285. set gazeTrackerMesh(value: Mesh);
  48286. /**
  48287. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  48288. */
  48289. updateGazeTrackerScale: boolean;
  48290. /**
  48291. * If the gaze trackers color should be updated when selecting meshes
  48292. */
  48293. updateGazeTrackerColor: boolean;
  48294. /**
  48295. * If the controller laser color should be updated when selecting meshes
  48296. */
  48297. updateControllerLaserColor: boolean;
  48298. /**
  48299. * The gaze tracking mesh corresponding to the left controller
  48300. */
  48301. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  48302. /**
  48303. * The gaze tracking mesh corresponding to the right controller
  48304. */
  48305. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  48306. /**
  48307. * If the ray of the gaze should be displayed.
  48308. */
  48309. get displayGaze(): boolean;
  48310. /**
  48311. * Sets if the ray of the gaze should be displayed.
  48312. */
  48313. set displayGaze(value: boolean);
  48314. /**
  48315. * If the ray of the LaserPointer should be displayed.
  48316. */
  48317. get displayLaserPointer(): boolean;
  48318. /**
  48319. * Sets if the ray of the LaserPointer should be displayed.
  48320. */
  48321. set displayLaserPointer(value: boolean);
  48322. /**
  48323. * The deviceOrientationCamera used as the camera when not in VR.
  48324. */
  48325. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  48326. /**
  48327. * Based on the current WebVR support, returns the current VR camera used.
  48328. */
  48329. get currentVRCamera(): Nullable<Camera>;
  48330. /**
  48331. * The webVRCamera which is used when in VR.
  48332. */
  48333. get webVRCamera(): WebVRFreeCamera;
  48334. /**
  48335. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  48336. */
  48337. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  48338. /**
  48339. * The html button that is used to trigger entering into VR.
  48340. */
  48341. get vrButton(): Nullable<HTMLButtonElement>;
  48342. private get _teleportationRequestInitiated();
  48343. /**
  48344. * Defines whether or not Pointer lock should be requested when switching to
  48345. * full screen.
  48346. */
  48347. requestPointerLockOnFullScreen: boolean;
  48348. /**
  48349. * If asking to force XR, this will be populated with the default xr experience
  48350. */
  48351. xr: WebXRDefaultExperience;
  48352. /**
  48353. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  48354. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  48355. */
  48356. xrTestDone: boolean;
  48357. /**
  48358. * Instantiates a VRExperienceHelper.
  48359. * Helps to quickly add VR support to an existing scene.
  48360. * @param scene The scene the VRExperienceHelper belongs to.
  48361. * @param webVROptions Options to modify the vr experience helper's behavior.
  48362. */
  48363. constructor(scene: Scene,
  48364. /** Options to modify the vr experience helper's behavior. */
  48365. webVROptions?: VRExperienceHelperOptions);
  48366. private completeVRInit;
  48367. private _onDefaultMeshLoaded;
  48368. private _onResize;
  48369. private _onFullscreenChange;
  48370. /**
  48371. * Gets a value indicating if we are currently in VR mode.
  48372. */
  48373. get isInVRMode(): boolean;
  48374. private onVrDisplayPresentChange;
  48375. private onVRDisplayChanged;
  48376. private moveButtonToBottomRight;
  48377. private displayVRButton;
  48378. private updateButtonVisibility;
  48379. private _cachedAngularSensibility;
  48380. /**
  48381. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  48382. * Otherwise, will use the fullscreen API.
  48383. */
  48384. enterVR(): void;
  48385. /**
  48386. * Attempt to exit VR, or fullscreen.
  48387. */
  48388. exitVR(): void;
  48389. /**
  48390. * The position of the vr experience helper.
  48391. */
  48392. get position(): Vector3;
  48393. /**
  48394. * Sets the position of the vr experience helper.
  48395. */
  48396. set position(value: Vector3);
  48397. /**
  48398. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  48399. */
  48400. enableInteractions(): void;
  48401. private get _noControllerIsActive();
  48402. private beforeRender;
  48403. private _isTeleportationFloor;
  48404. /**
  48405. * Adds a floor mesh to be used for teleportation.
  48406. * @param floorMesh the mesh to be used for teleportation.
  48407. */
  48408. addFloorMesh(floorMesh: Mesh): void;
  48409. /**
  48410. * Removes a floor mesh from being used for teleportation.
  48411. * @param floorMesh the mesh to be removed.
  48412. */
  48413. removeFloorMesh(floorMesh: Mesh): void;
  48414. /**
  48415. * Enables interactions and teleportation using the VR controllers and gaze.
  48416. * @param vrTeleportationOptions options to modify teleportation behavior.
  48417. */
  48418. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  48419. private _onNewGamepadConnected;
  48420. private _tryEnableInteractionOnController;
  48421. private _onNewGamepadDisconnected;
  48422. private _enableInteractionOnController;
  48423. private _checkTeleportWithRay;
  48424. private _checkRotate;
  48425. private _checkTeleportBackwards;
  48426. private _enableTeleportationOnController;
  48427. private _createTeleportationCircles;
  48428. private _displayTeleportationTarget;
  48429. private _hideTeleportationTarget;
  48430. private _rotateCamera;
  48431. private _moveTeleportationSelectorTo;
  48432. private _workingVector;
  48433. private _workingQuaternion;
  48434. private _workingMatrix;
  48435. /**
  48436. * Time Constant Teleportation Mode
  48437. */
  48438. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  48439. /**
  48440. * Speed Constant Teleportation Mode
  48441. */
  48442. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  48443. /**
  48444. * Teleports the users feet to the desired location
  48445. * @param location The location where the user's feet should be placed
  48446. */
  48447. teleportCamera(location: Vector3): void;
  48448. private _convertNormalToDirectionOfRay;
  48449. private _castRayAndSelectObject;
  48450. private _notifySelectedMeshUnselected;
  48451. /**
  48452. * Permanently set new colors for the laser pointer
  48453. * @param color the new laser color
  48454. * @param pickedColor the new laser color when picked mesh detected
  48455. */
  48456. setLaserColor(color: Color3, pickedColor?: Color3): void;
  48457. /**
  48458. * Set lighting enabled / disabled on the laser pointer of both controllers
  48459. * @param enabled should the lighting be enabled on the laser pointer
  48460. */
  48461. setLaserLightingState(enabled?: boolean): void;
  48462. /**
  48463. * Permanently set new colors for the gaze pointer
  48464. * @param color the new gaze color
  48465. * @param pickedColor the new gaze color when picked mesh detected
  48466. */
  48467. setGazeColor(color: Color3, pickedColor?: Color3): void;
  48468. /**
  48469. * Sets the color of the laser ray from the vr controllers.
  48470. * @param color new color for the ray.
  48471. */
  48472. changeLaserColor(color: Color3): void;
  48473. /**
  48474. * Sets the color of the ray from the vr headsets gaze.
  48475. * @param color new color for the ray.
  48476. */
  48477. changeGazeColor(color: Color3): void;
  48478. /**
  48479. * Exits VR and disposes of the vr experience helper
  48480. */
  48481. dispose(): void;
  48482. /**
  48483. * Gets the name of the VRExperienceHelper class
  48484. * @returns "VRExperienceHelper"
  48485. */
  48486. getClassName(): string;
  48487. }
  48488. }
  48489. declare module BABYLON {
  48490. /**
  48491. * Contains an array of blocks representing the octree
  48492. */
  48493. export interface IOctreeContainer<T> {
  48494. /**
  48495. * Blocks within the octree
  48496. */
  48497. blocks: Array<OctreeBlock<T>>;
  48498. }
  48499. /**
  48500. * Class used to store a cell in an octree
  48501. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48502. */
  48503. export class OctreeBlock<T> {
  48504. /**
  48505. * Gets the content of the current block
  48506. */
  48507. entries: T[];
  48508. /**
  48509. * Gets the list of block children
  48510. */
  48511. blocks: Array<OctreeBlock<T>>;
  48512. private _depth;
  48513. private _maxDepth;
  48514. private _capacity;
  48515. private _minPoint;
  48516. private _maxPoint;
  48517. private _boundingVectors;
  48518. private _creationFunc;
  48519. /**
  48520. * Creates a new block
  48521. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  48522. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  48523. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  48524. * @param depth defines the current depth of this block in the octree
  48525. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  48526. * @param creationFunc defines a callback to call when an element is added to the block
  48527. */
  48528. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  48529. /**
  48530. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  48531. */
  48532. get capacity(): number;
  48533. /**
  48534. * Gets the minimum vector (in world space) of the block's bounding box
  48535. */
  48536. get minPoint(): Vector3;
  48537. /**
  48538. * Gets the maximum vector (in world space) of the block's bounding box
  48539. */
  48540. get maxPoint(): Vector3;
  48541. /**
  48542. * Add a new element to this block
  48543. * @param entry defines the element to add
  48544. */
  48545. addEntry(entry: T): void;
  48546. /**
  48547. * Remove an element from this block
  48548. * @param entry defines the element to remove
  48549. */
  48550. removeEntry(entry: T): void;
  48551. /**
  48552. * Add an array of elements to this block
  48553. * @param entries defines the array of elements to add
  48554. */
  48555. addEntries(entries: T[]): void;
  48556. /**
  48557. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  48558. * @param frustumPlanes defines the frustum planes to test
  48559. * @param selection defines the array to store current content if selection is positive
  48560. * @param allowDuplicate defines if the selection array can contains duplicated entries
  48561. */
  48562. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  48563. /**
  48564. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  48565. * @param sphereCenter defines the bounding sphere center
  48566. * @param sphereRadius defines the bounding sphere radius
  48567. * @param selection defines the array to store current content if selection is positive
  48568. * @param allowDuplicate defines if the selection array can contains duplicated entries
  48569. */
  48570. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  48571. /**
  48572. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  48573. * @param ray defines the ray to test with
  48574. * @param selection defines the array to store current content if selection is positive
  48575. */
  48576. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  48577. /**
  48578. * Subdivide the content into child blocks (this block will then be empty)
  48579. */
  48580. createInnerBlocks(): void;
  48581. /**
  48582. * @hidden
  48583. */
  48584. 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;
  48585. }
  48586. }
  48587. declare module BABYLON {
  48588. /**
  48589. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  48590. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48591. */
  48592. export class Octree<T> {
  48593. /** 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.) */
  48594. maxDepth: number;
  48595. /**
  48596. * Blocks within the octree containing objects
  48597. */
  48598. blocks: Array<OctreeBlock<T>>;
  48599. /**
  48600. * Content stored in the octree
  48601. */
  48602. dynamicContent: T[];
  48603. private _maxBlockCapacity;
  48604. private _selectionContent;
  48605. private _creationFunc;
  48606. /**
  48607. * Creates a octree
  48608. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48609. * @param creationFunc function to be used to instatiate the octree
  48610. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  48611. * @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.)
  48612. */
  48613. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  48614. /** 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.) */
  48615. maxDepth?: number);
  48616. /**
  48617. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  48618. * @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);
  48619. * @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);
  48620. * @param entries meshes to be added to the octree blocks
  48621. */
  48622. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  48623. /**
  48624. * Adds a mesh to the octree
  48625. * @param entry Mesh to add to the octree
  48626. */
  48627. addMesh(entry: T): void;
  48628. /**
  48629. * Remove an element from the octree
  48630. * @param entry defines the element to remove
  48631. */
  48632. removeMesh(entry: T): void;
  48633. /**
  48634. * Selects an array of meshes within the frustum
  48635. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  48636. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  48637. * @returns array of meshes within the frustum
  48638. */
  48639. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  48640. /**
  48641. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  48642. * @param sphereCenter defines the bounding sphere center
  48643. * @param sphereRadius defines the bounding sphere radius
  48644. * @param allowDuplicate defines if the selection array can contains duplicated entries
  48645. * @returns an array of objects that intersect the sphere
  48646. */
  48647. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  48648. /**
  48649. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  48650. * @param ray defines the ray to test with
  48651. * @returns array of intersected objects
  48652. */
  48653. intersectsRay(ray: Ray): SmartArray<T>;
  48654. /**
  48655. * Adds a mesh into the octree block if it intersects the block
  48656. */
  48657. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  48658. /**
  48659. * Adds a submesh into the octree block if it intersects the block
  48660. */
  48661. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  48662. }
  48663. }
  48664. declare module BABYLON {
  48665. interface Scene {
  48666. /**
  48667. * @hidden
  48668. * Backing Filed
  48669. */
  48670. _selectionOctree: Octree<AbstractMesh>;
  48671. /**
  48672. * Gets the octree used to boost mesh selection (picking)
  48673. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48674. */
  48675. selectionOctree: Octree<AbstractMesh>;
  48676. /**
  48677. * Creates or updates the octree used to boost selection (picking)
  48678. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48679. * @param maxCapacity defines the maximum capacity per leaf
  48680. * @param maxDepth defines the maximum depth of the octree
  48681. * @returns an octree of AbstractMesh
  48682. */
  48683. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  48684. }
  48685. interface AbstractMesh {
  48686. /**
  48687. * @hidden
  48688. * Backing Field
  48689. */
  48690. _submeshesOctree: Octree<SubMesh>;
  48691. /**
  48692. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  48693. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  48694. * @param maxCapacity defines the maximum size of each block (64 by default)
  48695. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  48696. * @returns the new octree
  48697. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  48698. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48699. */
  48700. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  48701. }
  48702. /**
  48703. * Defines the octree scene component responsible to manage any octrees
  48704. * in a given scene.
  48705. */
  48706. export class OctreeSceneComponent {
  48707. /**
  48708. * The component name help to identify the component in the list of scene components.
  48709. */
  48710. readonly name: string;
  48711. /**
  48712. * The scene the component belongs to.
  48713. */
  48714. scene: Scene;
  48715. /**
  48716. * Indicates if the meshes have been checked to make sure they are isEnabled()
  48717. */
  48718. readonly checksIsEnabled: boolean;
  48719. /**
  48720. * Creates a new instance of the component for the given scene
  48721. * @param scene Defines the scene to register the component in
  48722. */
  48723. constructor(scene: Scene);
  48724. /**
  48725. * Registers the component in a given scene
  48726. */
  48727. register(): void;
  48728. /**
  48729. * Return the list of active meshes
  48730. * @returns the list of active meshes
  48731. */
  48732. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  48733. /**
  48734. * Return the list of active sub meshes
  48735. * @param mesh The mesh to get the candidates sub meshes from
  48736. * @returns the list of active sub meshes
  48737. */
  48738. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  48739. private _tempRay;
  48740. /**
  48741. * Return the list of sub meshes intersecting with a given local ray
  48742. * @param mesh defines the mesh to find the submesh for
  48743. * @param localRay defines the ray in local space
  48744. * @returns the list of intersecting sub meshes
  48745. */
  48746. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  48747. /**
  48748. * Return the list of sub meshes colliding with a collider
  48749. * @param mesh defines the mesh to find the submesh for
  48750. * @param collider defines the collider to evaluate the collision against
  48751. * @returns the list of colliding sub meshes
  48752. */
  48753. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  48754. /**
  48755. * Rebuilds the elements related to this component in case of
  48756. * context lost for instance.
  48757. */
  48758. rebuild(): void;
  48759. /**
  48760. * Disposes the component and the associated ressources.
  48761. */
  48762. dispose(): void;
  48763. }
  48764. }
  48765. declare module BABYLON {
  48766. /**
  48767. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  48768. */
  48769. export class Gizmo implements IDisposable {
  48770. /** The utility layer the gizmo will be added to */
  48771. gizmoLayer: UtilityLayerRenderer;
  48772. /**
  48773. * The root mesh of the gizmo
  48774. */
  48775. _rootMesh: Mesh;
  48776. private _attachedMesh;
  48777. /**
  48778. * Ratio for the scale of the gizmo (Default: 1)
  48779. */
  48780. scaleRatio: number;
  48781. /**
  48782. * If a custom mesh has been set (Default: false)
  48783. */
  48784. protected _customMeshSet: boolean;
  48785. /**
  48786. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  48787. * * When set, interactions will be enabled
  48788. */
  48789. get attachedMesh(): Nullable<AbstractMesh>;
  48790. set attachedMesh(value: Nullable<AbstractMesh>);
  48791. /**
  48792. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48793. * @param mesh The mesh to replace the default mesh of the gizmo
  48794. */
  48795. setCustomMesh(mesh: Mesh): void;
  48796. /**
  48797. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  48798. */
  48799. updateGizmoRotationToMatchAttachedMesh: boolean;
  48800. /**
  48801. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  48802. */
  48803. updateGizmoPositionToMatchAttachedMesh: boolean;
  48804. /**
  48805. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  48806. */
  48807. updateScale: boolean;
  48808. protected _interactionsEnabled: boolean;
  48809. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48810. private _beforeRenderObserver;
  48811. private _tempVector;
  48812. /**
  48813. * Creates a gizmo
  48814. * @param gizmoLayer The utility layer the gizmo will be added to
  48815. */
  48816. constructor(
  48817. /** The utility layer the gizmo will be added to */
  48818. gizmoLayer?: UtilityLayerRenderer);
  48819. /**
  48820. * Updates the gizmo to match the attached mesh's position/rotation
  48821. */
  48822. protected _update(): void;
  48823. /**
  48824. * Disposes of the gizmo
  48825. */
  48826. dispose(): void;
  48827. }
  48828. }
  48829. declare module BABYLON {
  48830. /**
  48831. * Single plane drag gizmo
  48832. */
  48833. export class PlaneDragGizmo extends Gizmo {
  48834. /**
  48835. * Drag behavior responsible for the gizmos dragging interactions
  48836. */
  48837. dragBehavior: PointerDragBehavior;
  48838. private _pointerObserver;
  48839. /**
  48840. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48841. */
  48842. snapDistance: number;
  48843. /**
  48844. * Event that fires each time the gizmo snaps to a new location.
  48845. * * snapDistance is the the change in distance
  48846. */
  48847. onSnapObservable: Observable<{
  48848. snapDistance: number;
  48849. }>;
  48850. private _plane;
  48851. private _coloredMaterial;
  48852. private _hoverMaterial;
  48853. private _isEnabled;
  48854. private _parent;
  48855. /** @hidden */
  48856. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  48857. /** @hidden */
  48858. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  48859. /**
  48860. * Creates a PlaneDragGizmo
  48861. * @param gizmoLayer The utility layer the gizmo will be added to
  48862. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  48863. * @param color The color of the gizmo
  48864. */
  48865. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  48866. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48867. /**
  48868. * If the gizmo is enabled
  48869. */
  48870. set isEnabled(value: boolean);
  48871. get isEnabled(): boolean;
  48872. /**
  48873. * Disposes of the gizmo
  48874. */
  48875. dispose(): void;
  48876. }
  48877. }
  48878. declare module BABYLON {
  48879. /**
  48880. * Gizmo that enables dragging a mesh along 3 axis
  48881. */
  48882. export class PositionGizmo extends Gizmo {
  48883. /**
  48884. * Internal gizmo used for interactions on the x axis
  48885. */
  48886. xGizmo: AxisDragGizmo;
  48887. /**
  48888. * Internal gizmo used for interactions on the y axis
  48889. */
  48890. yGizmo: AxisDragGizmo;
  48891. /**
  48892. * Internal gizmo used for interactions on the z axis
  48893. */
  48894. zGizmo: AxisDragGizmo;
  48895. /**
  48896. * Internal gizmo used for interactions on the yz plane
  48897. */
  48898. xPlaneGizmo: PlaneDragGizmo;
  48899. /**
  48900. * Internal gizmo used for interactions on the xz plane
  48901. */
  48902. yPlaneGizmo: PlaneDragGizmo;
  48903. /**
  48904. * Internal gizmo used for interactions on the xy plane
  48905. */
  48906. zPlaneGizmo: PlaneDragGizmo;
  48907. /**
  48908. * private variables
  48909. */
  48910. private _meshAttached;
  48911. private _updateGizmoRotationToMatchAttachedMesh;
  48912. private _snapDistance;
  48913. private _scaleRatio;
  48914. /** Fires an event when any of it's sub gizmos are dragged */
  48915. onDragStartObservable: Observable<unknown>;
  48916. /** Fires an event when any of it's sub gizmos are released from dragging */
  48917. onDragEndObservable: Observable<unknown>;
  48918. /**
  48919. * If set to true, planar drag is enabled
  48920. */
  48921. private _planarGizmoEnabled;
  48922. get attachedMesh(): Nullable<AbstractMesh>;
  48923. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48924. /**
  48925. * Creates a PositionGizmo
  48926. * @param gizmoLayer The utility layer the gizmo will be added to
  48927. */
  48928. constructor(gizmoLayer?: UtilityLayerRenderer);
  48929. /**
  48930. * If the planar drag gizmo is enabled
  48931. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  48932. */
  48933. set planarGizmoEnabled(value: boolean);
  48934. get planarGizmoEnabled(): boolean;
  48935. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48936. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48937. /**
  48938. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48939. */
  48940. set snapDistance(value: number);
  48941. get snapDistance(): number;
  48942. /**
  48943. * Ratio for the scale of the gizmo (Default: 1)
  48944. */
  48945. set scaleRatio(value: number);
  48946. get scaleRatio(): number;
  48947. /**
  48948. * Disposes of the gizmo
  48949. */
  48950. dispose(): void;
  48951. /**
  48952. * CustomMeshes are not supported by this gizmo
  48953. * @param mesh The mesh to replace the default mesh of the gizmo
  48954. */
  48955. setCustomMesh(mesh: Mesh): void;
  48956. }
  48957. }
  48958. declare module BABYLON {
  48959. /**
  48960. * Single axis drag gizmo
  48961. */
  48962. export class AxisDragGizmo extends Gizmo {
  48963. /**
  48964. * Drag behavior responsible for the gizmos dragging interactions
  48965. */
  48966. dragBehavior: PointerDragBehavior;
  48967. private _pointerObserver;
  48968. /**
  48969. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48970. */
  48971. snapDistance: number;
  48972. /**
  48973. * Event that fires each time the gizmo snaps to a new location.
  48974. * * snapDistance is the the change in distance
  48975. */
  48976. onSnapObservable: Observable<{
  48977. snapDistance: number;
  48978. }>;
  48979. private _isEnabled;
  48980. private _parent;
  48981. private _arrow;
  48982. private _coloredMaterial;
  48983. private _hoverMaterial;
  48984. /** @hidden */
  48985. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  48986. /** @hidden */
  48987. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  48988. /**
  48989. * Creates an AxisDragGizmo
  48990. * @param gizmoLayer The utility layer the gizmo will be added to
  48991. * @param dragAxis The axis which the gizmo will be able to drag on
  48992. * @param color The color of the gizmo
  48993. */
  48994. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  48995. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48996. /**
  48997. * If the gizmo is enabled
  48998. */
  48999. set isEnabled(value: boolean);
  49000. get isEnabled(): boolean;
  49001. /**
  49002. * Disposes of the gizmo
  49003. */
  49004. dispose(): void;
  49005. }
  49006. }
  49007. declare module BABYLON.Debug {
  49008. /**
  49009. * The Axes viewer will show 3 axes in a specific point in space
  49010. */
  49011. export class AxesViewer {
  49012. private _xAxis;
  49013. private _yAxis;
  49014. private _zAxis;
  49015. private _scaleLinesFactor;
  49016. private _instanced;
  49017. /**
  49018. * Gets the hosting scene
  49019. */
  49020. scene: Scene;
  49021. /**
  49022. * Gets or sets a number used to scale line length
  49023. */
  49024. scaleLines: number;
  49025. /** Gets the node hierarchy used to render x-axis */
  49026. get xAxis(): TransformNode;
  49027. /** Gets the node hierarchy used to render y-axis */
  49028. get yAxis(): TransformNode;
  49029. /** Gets the node hierarchy used to render z-axis */
  49030. get zAxis(): TransformNode;
  49031. /**
  49032. * Creates a new AxesViewer
  49033. * @param scene defines the hosting scene
  49034. * @param scaleLines defines a number used to scale line length (1 by default)
  49035. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  49036. * @param xAxis defines the node hierarchy used to render the x-axis
  49037. * @param yAxis defines the node hierarchy used to render the y-axis
  49038. * @param zAxis defines the node hierarchy used to render the z-axis
  49039. */
  49040. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  49041. /**
  49042. * Force the viewer to update
  49043. * @param position defines the position of the viewer
  49044. * @param xaxis defines the x axis of the viewer
  49045. * @param yaxis defines the y axis of the viewer
  49046. * @param zaxis defines the z axis of the viewer
  49047. */
  49048. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  49049. /**
  49050. * Creates an instance of this axes viewer.
  49051. * @returns a new axes viewer with instanced meshes
  49052. */
  49053. createInstance(): AxesViewer;
  49054. /** Releases resources */
  49055. dispose(): void;
  49056. private static _SetRenderingGroupId;
  49057. }
  49058. }
  49059. declare module BABYLON.Debug {
  49060. /**
  49061. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  49062. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  49063. */
  49064. export class BoneAxesViewer extends AxesViewer {
  49065. /**
  49066. * Gets or sets the target mesh where to display the axes viewer
  49067. */
  49068. mesh: Nullable<Mesh>;
  49069. /**
  49070. * Gets or sets the target bone where to display the axes viewer
  49071. */
  49072. bone: Nullable<Bone>;
  49073. /** Gets current position */
  49074. pos: Vector3;
  49075. /** Gets direction of X axis */
  49076. xaxis: Vector3;
  49077. /** Gets direction of Y axis */
  49078. yaxis: Vector3;
  49079. /** Gets direction of Z axis */
  49080. zaxis: Vector3;
  49081. /**
  49082. * Creates a new BoneAxesViewer
  49083. * @param scene defines the hosting scene
  49084. * @param bone defines the target bone
  49085. * @param mesh defines the target mesh
  49086. * @param scaleLines defines a scaling factor for line length (1 by default)
  49087. */
  49088. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  49089. /**
  49090. * Force the viewer to update
  49091. */
  49092. update(): void;
  49093. /** Releases resources */
  49094. dispose(): void;
  49095. }
  49096. }
  49097. declare module BABYLON {
  49098. /**
  49099. * Interface used to define scene explorer extensibility option
  49100. */
  49101. export interface IExplorerExtensibilityOption {
  49102. /**
  49103. * Define the option label
  49104. */
  49105. label: string;
  49106. /**
  49107. * Defines the action to execute on click
  49108. */
  49109. action: (entity: any) => void;
  49110. }
  49111. /**
  49112. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  49113. */
  49114. export interface IExplorerExtensibilityGroup {
  49115. /**
  49116. * Defines a predicate to test if a given type mut be extended
  49117. */
  49118. predicate: (entity: any) => boolean;
  49119. /**
  49120. * Gets the list of options added to a type
  49121. */
  49122. entries: IExplorerExtensibilityOption[];
  49123. }
  49124. /**
  49125. * Interface used to define the options to use to create the Inspector
  49126. */
  49127. export interface IInspectorOptions {
  49128. /**
  49129. * Display in overlay mode (default: false)
  49130. */
  49131. overlay?: boolean;
  49132. /**
  49133. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  49134. */
  49135. globalRoot?: HTMLElement;
  49136. /**
  49137. * Display the Scene explorer
  49138. */
  49139. showExplorer?: boolean;
  49140. /**
  49141. * Display the property inspector
  49142. */
  49143. showInspector?: boolean;
  49144. /**
  49145. * Display in embed mode (both panes on the right)
  49146. */
  49147. embedMode?: boolean;
  49148. /**
  49149. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  49150. */
  49151. handleResize?: boolean;
  49152. /**
  49153. * Allow the panes to popup (default: true)
  49154. */
  49155. enablePopup?: boolean;
  49156. /**
  49157. * Allow the panes to be closed by users (default: true)
  49158. */
  49159. enableClose?: boolean;
  49160. /**
  49161. * Optional list of extensibility entries
  49162. */
  49163. explorerExtensibility?: IExplorerExtensibilityGroup[];
  49164. /**
  49165. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  49166. */
  49167. inspectorURL?: string;
  49168. /**
  49169. * Optional initial tab (default to DebugLayerTab.Properties)
  49170. */
  49171. initialTab?: DebugLayerTab;
  49172. }
  49173. interface Scene {
  49174. /**
  49175. * @hidden
  49176. * Backing field
  49177. */
  49178. _debugLayer: DebugLayer;
  49179. /**
  49180. * Gets the debug layer (aka Inspector) associated with the scene
  49181. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49182. */
  49183. debugLayer: DebugLayer;
  49184. }
  49185. /**
  49186. * Enum of inspector action tab
  49187. */
  49188. export enum DebugLayerTab {
  49189. /**
  49190. * Properties tag (default)
  49191. */
  49192. Properties = 0,
  49193. /**
  49194. * Debug tab
  49195. */
  49196. Debug = 1,
  49197. /**
  49198. * Statistics tab
  49199. */
  49200. Statistics = 2,
  49201. /**
  49202. * Tools tab
  49203. */
  49204. Tools = 3,
  49205. /**
  49206. * Settings tab
  49207. */
  49208. Settings = 4
  49209. }
  49210. /**
  49211. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49212. * what is happening in your scene
  49213. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49214. */
  49215. export class DebugLayer {
  49216. /**
  49217. * Define the url to get the inspector script from.
  49218. * By default it uses the babylonjs CDN.
  49219. * @ignoreNaming
  49220. */
  49221. static InspectorURL: string;
  49222. private _scene;
  49223. private BJSINSPECTOR;
  49224. private _onPropertyChangedObservable?;
  49225. /**
  49226. * Observable triggered when a property is changed through the inspector.
  49227. */
  49228. get onPropertyChangedObservable(): any;
  49229. /**
  49230. * Instantiates a new debug layer.
  49231. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49232. * what is happening in your scene
  49233. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49234. * @param scene Defines the scene to inspect
  49235. */
  49236. constructor(scene: Scene);
  49237. /** Creates the inspector window. */
  49238. private _createInspector;
  49239. /**
  49240. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  49241. * @param entity defines the entity to select
  49242. * @param lineContainerTitle defines the specific block to highlight
  49243. */
  49244. select(entity: any, lineContainerTitle?: string): void;
  49245. /** Get the inspector from bundle or global */
  49246. private _getGlobalInspector;
  49247. /**
  49248. * Get if the inspector is visible or not.
  49249. * @returns true if visible otherwise, false
  49250. */
  49251. isVisible(): boolean;
  49252. /**
  49253. * Hide the inspector and close its window.
  49254. */
  49255. hide(): void;
  49256. /**
  49257. * Update the scene in the inspector
  49258. */
  49259. setAsActiveScene(): void;
  49260. /**
  49261. * Launch the debugLayer.
  49262. * @param config Define the configuration of the inspector
  49263. * @return a promise fulfilled when the debug layer is visible
  49264. */
  49265. show(config?: IInspectorOptions): Promise<DebugLayer>;
  49266. }
  49267. }
  49268. declare module BABYLON {
  49269. /**
  49270. * Class containing static functions to help procedurally build meshes
  49271. */
  49272. export class BoxBuilder {
  49273. /**
  49274. * Creates a box mesh
  49275. * * The parameter `size` sets the size (float) of each box side (default 1)
  49276. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  49277. * * 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)
  49278. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49279. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49280. * * 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
  49281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49282. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  49283. * @param name defines the name of the mesh
  49284. * @param options defines the options used to create the mesh
  49285. * @param scene defines the hosting scene
  49286. * @returns the box mesh
  49287. */
  49288. static CreateBox(name: string, options: {
  49289. size?: number;
  49290. width?: number;
  49291. height?: number;
  49292. depth?: number;
  49293. faceUV?: Vector4[];
  49294. faceColors?: Color4[];
  49295. sideOrientation?: number;
  49296. frontUVs?: Vector4;
  49297. backUVs?: Vector4;
  49298. wrap?: boolean;
  49299. topBaseAt?: number;
  49300. bottomBaseAt?: number;
  49301. updatable?: boolean;
  49302. }, scene?: Nullable<Scene>): Mesh;
  49303. }
  49304. }
  49305. declare module BABYLON.Debug {
  49306. /**
  49307. * Used to show the physics impostor around the specific mesh
  49308. */
  49309. export class PhysicsViewer {
  49310. /** @hidden */
  49311. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  49312. /** @hidden */
  49313. protected _meshes: Array<Nullable<AbstractMesh>>;
  49314. /** @hidden */
  49315. protected _scene: Nullable<Scene>;
  49316. /** @hidden */
  49317. protected _numMeshes: number;
  49318. /** @hidden */
  49319. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  49320. private _renderFunction;
  49321. private _utilityLayer;
  49322. private _debugBoxMesh;
  49323. private _debugSphereMesh;
  49324. private _debugCylinderMesh;
  49325. private _debugMaterial;
  49326. private _debugMeshMeshes;
  49327. /**
  49328. * Creates a new PhysicsViewer
  49329. * @param scene defines the hosting scene
  49330. */
  49331. constructor(scene: Scene);
  49332. /** @hidden */
  49333. protected _updateDebugMeshes(): void;
  49334. /**
  49335. * Renders a specified physic impostor
  49336. * @param impostor defines the impostor to render
  49337. * @param targetMesh defines the mesh represented by the impostor
  49338. * @returns the new debug mesh used to render the impostor
  49339. */
  49340. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  49341. /**
  49342. * Hides a specified physic impostor
  49343. * @param impostor defines the impostor to hide
  49344. */
  49345. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  49346. private _getDebugMaterial;
  49347. private _getDebugBoxMesh;
  49348. private _getDebugSphereMesh;
  49349. private _getDebugCylinderMesh;
  49350. private _getDebugMeshMesh;
  49351. private _getDebugMesh;
  49352. /** Releases all resources */
  49353. dispose(): void;
  49354. }
  49355. }
  49356. declare module BABYLON {
  49357. /**
  49358. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  49359. * in order to better appreciate the issue one might have.
  49360. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  49361. */
  49362. export class RayHelper {
  49363. /**
  49364. * Defines the ray we are currently tryin to visualize.
  49365. */
  49366. ray: Nullable<Ray>;
  49367. private _renderPoints;
  49368. private _renderLine;
  49369. private _renderFunction;
  49370. private _scene;
  49371. private _updateToMeshFunction;
  49372. private _attachedToMesh;
  49373. private _meshSpaceDirection;
  49374. private _meshSpaceOrigin;
  49375. /**
  49376. * Helper function to create a colored helper in a scene in one line.
  49377. * @param ray Defines the ray we are currently tryin to visualize
  49378. * @param scene Defines the scene the ray is used in
  49379. * @param color Defines the color we want to see the ray in
  49380. * @returns The newly created ray helper.
  49381. */
  49382. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  49383. /**
  49384. * Instantiate a new ray helper.
  49385. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  49386. * in order to better appreciate the issue one might have.
  49387. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  49388. * @param ray Defines the ray we are currently tryin to visualize
  49389. */
  49390. constructor(ray: Ray);
  49391. /**
  49392. * Shows the ray we are willing to debug.
  49393. * @param scene Defines the scene the ray needs to be rendered in
  49394. * @param color Defines the color the ray needs to be rendered in
  49395. */
  49396. show(scene: Scene, color?: Color3): void;
  49397. /**
  49398. * Hides the ray we are debugging.
  49399. */
  49400. hide(): void;
  49401. private _render;
  49402. /**
  49403. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  49404. * @param mesh Defines the mesh we want the helper attached to
  49405. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  49406. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  49407. * @param length Defines the length of the ray
  49408. */
  49409. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  49410. /**
  49411. * Detach the ray helper from the mesh it has previously been attached to.
  49412. */
  49413. detachFromMesh(): void;
  49414. private _updateToMesh;
  49415. /**
  49416. * Dispose the helper and release its associated resources.
  49417. */
  49418. dispose(): void;
  49419. }
  49420. }
  49421. declare module BABYLON.Debug {
  49422. /**
  49423. * Class used to render a debug view of a given skeleton
  49424. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  49425. */
  49426. export class SkeletonViewer {
  49427. /** defines the skeleton to render */
  49428. skeleton: Skeleton;
  49429. /** defines the mesh attached to the skeleton */
  49430. mesh: AbstractMesh;
  49431. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  49432. autoUpdateBonesMatrices: boolean;
  49433. /** defines the rendering group id to use with the viewer */
  49434. renderingGroupId: number;
  49435. /** Gets or sets the color used to render the skeleton */
  49436. color: Color3;
  49437. private _scene;
  49438. private _debugLines;
  49439. private _debugMesh;
  49440. private _isEnabled;
  49441. private _renderFunction;
  49442. private _utilityLayer;
  49443. /**
  49444. * Returns the mesh used to render the bones
  49445. */
  49446. get debugMesh(): Nullable<LinesMesh>;
  49447. /**
  49448. * Creates a new SkeletonViewer
  49449. * @param skeleton defines the skeleton to render
  49450. * @param mesh defines the mesh attached to the skeleton
  49451. * @param scene defines the hosting scene
  49452. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  49453. * @param renderingGroupId defines the rendering group id to use with the viewer
  49454. */
  49455. constructor(
  49456. /** defines the skeleton to render */
  49457. skeleton: Skeleton,
  49458. /** defines the mesh attached to the skeleton */
  49459. mesh: AbstractMesh, scene: Scene,
  49460. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  49461. autoUpdateBonesMatrices?: boolean,
  49462. /** defines the rendering group id to use with the viewer */
  49463. renderingGroupId?: number);
  49464. /** Gets or sets a boolean indicating if the viewer is enabled */
  49465. set isEnabled(value: boolean);
  49466. get isEnabled(): boolean;
  49467. private _getBonePosition;
  49468. private _getLinesForBonesWithLength;
  49469. private _getLinesForBonesNoLength;
  49470. /** Update the viewer to sync with current skeleton state */
  49471. update(): void;
  49472. /** Release associated resources */
  49473. dispose(): void;
  49474. }
  49475. }
  49476. declare module BABYLON {
  49477. /**
  49478. * Enum for Device Types
  49479. */
  49480. export enum DeviceType {
  49481. /** Generic */
  49482. Generic = 0,
  49483. /** Keyboard */
  49484. Keyboard = 1,
  49485. /** Mouse */
  49486. Mouse = 2,
  49487. /** Touch Pointers */
  49488. Touch = 3,
  49489. /** PS4 Dual Shock */
  49490. DualShock = 4,
  49491. /** Xbox */
  49492. Xbox = 5,
  49493. /** Switch Controller */
  49494. Switch = 6
  49495. }
  49496. /**
  49497. * Enum for All Pointers (Touch/Mouse)
  49498. */
  49499. export enum PointerInput {
  49500. /** Horizontal Axis */
  49501. Horizontal = 0,
  49502. /** Vertical Axis */
  49503. Vertical = 1,
  49504. /** Left Click or Touch */
  49505. LeftClick = 2,
  49506. /** Middle Click */
  49507. MiddleClick = 3,
  49508. /** Right Click */
  49509. RightClick = 4,
  49510. /** Browser Back */
  49511. BrowserBack = 5,
  49512. /** Browser Forward */
  49513. BrowserForward = 6
  49514. }
  49515. /**
  49516. * Enum for Dual Shock Gamepad
  49517. */
  49518. export enum DualShockInput {
  49519. /** Cross */
  49520. Cross = 0,
  49521. /** Circle */
  49522. Circle = 1,
  49523. /** Square */
  49524. Square = 2,
  49525. /** Triangle */
  49526. Triangle = 3,
  49527. /** L1 */
  49528. L1 = 4,
  49529. /** R1 */
  49530. R1 = 5,
  49531. /** L2 */
  49532. L2 = 6,
  49533. /** R2 */
  49534. R2 = 7,
  49535. /** Share */
  49536. Share = 8,
  49537. /** Options */
  49538. Options = 9,
  49539. /** L3 */
  49540. L3 = 10,
  49541. /** R3 */
  49542. R3 = 11,
  49543. /** DPadUp */
  49544. DPadUp = 12,
  49545. /** DPadDown */
  49546. DPadDown = 13,
  49547. /** DPadLeft */
  49548. DPadLeft = 14,
  49549. /** DRight */
  49550. DPadRight = 15,
  49551. /** Home */
  49552. Home = 16,
  49553. /** TouchPad */
  49554. TouchPad = 17,
  49555. /** LStickXAxis */
  49556. LStickXAxis = 18,
  49557. /** LStickYAxis */
  49558. LStickYAxis = 19,
  49559. /** RStickXAxis */
  49560. RStickXAxis = 20,
  49561. /** RStickYAxis */
  49562. RStickYAxis = 21
  49563. }
  49564. /**
  49565. * Enum for Xbox Gamepad
  49566. */
  49567. export enum XboxInput {
  49568. /** A */
  49569. A = 0,
  49570. /** B */
  49571. B = 1,
  49572. /** X */
  49573. X = 2,
  49574. /** Y */
  49575. Y = 3,
  49576. /** LB */
  49577. LB = 4,
  49578. /** RB */
  49579. RB = 5,
  49580. /** LT */
  49581. LT = 6,
  49582. /** RT */
  49583. RT = 7,
  49584. /** Back */
  49585. Back = 8,
  49586. /** Start */
  49587. Start = 9,
  49588. /** LS */
  49589. LS = 10,
  49590. /** RS */
  49591. RS = 11,
  49592. /** DPadUp */
  49593. DPadUp = 12,
  49594. /** DPadDown */
  49595. DPadDown = 13,
  49596. /** DPadLeft */
  49597. DPadLeft = 14,
  49598. /** DRight */
  49599. DPadRight = 15,
  49600. /** Home */
  49601. Home = 16,
  49602. /** LStickXAxis */
  49603. LStickXAxis = 17,
  49604. /** LStickYAxis */
  49605. LStickYAxis = 18,
  49606. /** RStickXAxis */
  49607. RStickXAxis = 19,
  49608. /** RStickYAxis */
  49609. RStickYAxis = 20
  49610. }
  49611. /**
  49612. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  49613. */
  49614. export enum SwitchInput {
  49615. /** B */
  49616. B = 0,
  49617. /** A */
  49618. A = 1,
  49619. /** Y */
  49620. Y = 2,
  49621. /** X */
  49622. X = 3,
  49623. /** L */
  49624. L = 4,
  49625. /** R */
  49626. R = 5,
  49627. /** ZL */
  49628. ZL = 6,
  49629. /** ZR */
  49630. ZR = 7,
  49631. /** Minus */
  49632. Minus = 8,
  49633. /** Plus */
  49634. Plus = 9,
  49635. /** LS */
  49636. LS = 10,
  49637. /** RS */
  49638. RS = 11,
  49639. /** DPadUp */
  49640. DPadUp = 12,
  49641. /** DPadDown */
  49642. DPadDown = 13,
  49643. /** DPadLeft */
  49644. DPadLeft = 14,
  49645. /** DRight */
  49646. DPadRight = 15,
  49647. /** Home */
  49648. Home = 16,
  49649. /** Capture */
  49650. Capture = 17,
  49651. /** LStickXAxis */
  49652. LStickXAxis = 18,
  49653. /** LStickYAxis */
  49654. LStickYAxis = 19,
  49655. /** RStickXAxis */
  49656. RStickXAxis = 20,
  49657. /** RStickYAxis */
  49658. RStickYAxis = 21
  49659. }
  49660. }
  49661. declare module BABYLON {
  49662. /**
  49663. * This class will take all inputs from Keyboard, Pointer, and
  49664. * any Gamepads and provide a polling system that all devices
  49665. * will use. This class assumes that there will only be one
  49666. * pointer device and one keyboard.
  49667. */
  49668. export class DeviceInputSystem implements IDisposable {
  49669. /**
  49670. * Callback to be triggered when a device is connected
  49671. */
  49672. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  49673. /**
  49674. * Callback to be triggered when a device is disconnected
  49675. */
  49676. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  49677. /**
  49678. * Callback to be triggered when event driven input is updated
  49679. */
  49680. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  49681. private _inputs;
  49682. private _gamepads;
  49683. private _keyboardActive;
  49684. private _pointerActive;
  49685. private _elementToAttachTo;
  49686. private _keyboardDownEvent;
  49687. private _keyboardUpEvent;
  49688. private _pointerMoveEvent;
  49689. private _pointerDownEvent;
  49690. private _pointerUpEvent;
  49691. private _gamepadConnectedEvent;
  49692. private _gamepadDisconnectedEvent;
  49693. private static _MAX_KEYCODES;
  49694. private static _MAX_POINTER_INPUTS;
  49695. /**
  49696. * Default Constructor
  49697. * @param engine - engine to pull input element from
  49698. */
  49699. constructor(engine: Engine);
  49700. /**
  49701. * Checks for current device input value, given an id and input index
  49702. * @param deviceName Id of connected device
  49703. * @param inputIndex Index of device input
  49704. * @returns Current value of input
  49705. */
  49706. /**
  49707. * Checks for current device input value, given an id and input index
  49708. * @param deviceType Enum specifiying device type
  49709. * @param deviceSlot "Slot" or index that device is referenced in
  49710. * @param inputIndex Id of input to be checked
  49711. * @returns Current value of input
  49712. */
  49713. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  49714. /**
  49715. * Dispose of all the eventlisteners
  49716. */
  49717. dispose(): void;
  49718. /**
  49719. * Add device and inputs to device array
  49720. * @param deviceType Enum specifiying device type
  49721. * @param deviceSlot "Slot" or index that device is referenced in
  49722. * @param numberOfInputs Number of input entries to create for given device
  49723. */
  49724. private _registerDevice;
  49725. /**
  49726. * Given a specific device name, remove that device from the device map
  49727. * @param deviceType Enum specifiying device type
  49728. * @param deviceSlot "Slot" or index that device is referenced in
  49729. */
  49730. private _unregisterDevice;
  49731. /**
  49732. * Handle all actions that come from keyboard interaction
  49733. */
  49734. private _handleKeyActions;
  49735. /**
  49736. * Handle all actions that come from pointer interaction
  49737. */
  49738. private _handlePointerActions;
  49739. /**
  49740. * Handle all actions that come from gamepad interaction
  49741. */
  49742. private _handleGamepadActions;
  49743. /**
  49744. * Update all non-event based devices with each frame
  49745. * @param deviceType Enum specifiying device type
  49746. * @param deviceSlot "Slot" or index that device is referenced in
  49747. * @param inputIndex Id of input to be checked
  49748. */
  49749. private _updateDevice;
  49750. /**
  49751. * Gets DeviceType from the device name
  49752. * @param deviceName Name of Device from DeviceInputSystem
  49753. * @returns DeviceType enum value
  49754. */
  49755. private _getGamepadDeviceType;
  49756. }
  49757. }
  49758. declare module BABYLON {
  49759. /**
  49760. * Type to handle enforcement of inputs
  49761. */
  49762. 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;
  49763. }
  49764. declare module BABYLON {
  49765. /**
  49766. * Class that handles all input for a specific device
  49767. */
  49768. export class DeviceSource<T extends DeviceType> {
  49769. /** Type of device */
  49770. readonly deviceType: DeviceType;
  49771. /** "Slot" or index that device is referenced in */
  49772. readonly deviceSlot: number;
  49773. /**
  49774. * Observable to handle device input changes per device
  49775. */
  49776. readonly onInputChangedObservable: Observable<{
  49777. inputIndex: DeviceInput<T>;
  49778. previousState: Nullable<number>;
  49779. currentState: Nullable<number>;
  49780. }>;
  49781. private readonly _deviceInputSystem;
  49782. /**
  49783. * Default Constructor
  49784. * @param deviceInputSystem Reference to DeviceInputSystem
  49785. * @param deviceType Type of device
  49786. * @param deviceSlot "Slot" or index that device is referenced in
  49787. */
  49788. constructor(deviceInputSystem: DeviceInputSystem,
  49789. /** Type of device */
  49790. deviceType: DeviceType,
  49791. /** "Slot" or index that device is referenced in */
  49792. deviceSlot?: number);
  49793. /**
  49794. * Get input for specific input
  49795. * @param inputIndex index of specific input on device
  49796. * @returns Input value from DeviceInputSystem
  49797. */
  49798. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  49799. }
  49800. /**
  49801. * Class to keep track of devices
  49802. */
  49803. export class DeviceSourceManager implements IDisposable {
  49804. /**
  49805. * Observable to be triggered when before a device is connected
  49806. */
  49807. readonly onBeforeDeviceConnectedObservable: Observable<{
  49808. deviceType: DeviceType;
  49809. deviceSlot: number;
  49810. }>;
  49811. /**
  49812. * Observable to be triggered when before a device is disconnected
  49813. */
  49814. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  49815. deviceType: DeviceType;
  49816. deviceSlot: number;
  49817. }>;
  49818. /**
  49819. * Observable to be triggered when after a device is connected
  49820. */
  49821. readonly onAfterDeviceConnectedObservable: Observable<{
  49822. deviceType: DeviceType;
  49823. deviceSlot: number;
  49824. }>;
  49825. /**
  49826. * Observable to be triggered when after a device is disconnected
  49827. */
  49828. readonly onAfterDeviceDisconnectedObservable: Observable<{
  49829. deviceType: DeviceType;
  49830. deviceSlot: number;
  49831. }>;
  49832. private readonly _devices;
  49833. private readonly _firstDevice;
  49834. private readonly _deviceInputSystem;
  49835. /**
  49836. * Default Constructor
  49837. * @param engine engine to pull input element from
  49838. */
  49839. constructor(engine: Engine);
  49840. /**
  49841. * Gets a DeviceSource, given a type and slot
  49842. * @param deviceType Enum specifying device type
  49843. * @param deviceSlot "Slot" or index that device is referenced in
  49844. * @returns DeviceSource object
  49845. */
  49846. getDeviceSource<T extends DeviceType>(deviceType: DeviceType, deviceSlot?: number): Nullable<DeviceSource<T>>;
  49847. /**
  49848. * Gets an array of DeviceSource objects for a given device type
  49849. * @param deviceType Enum specifying device type
  49850. * @returns Array of DeviceSource objects
  49851. */
  49852. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  49853. /**
  49854. * Dispose of DeviceInputSystem and other parts
  49855. */
  49856. dispose(): void;
  49857. /**
  49858. * Function to add device name to device list
  49859. * @param deviceType Enum specifying device type
  49860. * @param deviceSlot "Slot" or index that device is referenced in
  49861. */
  49862. private _addDevice;
  49863. /**
  49864. * Function to remove device name to device list
  49865. * @param deviceType Enum specifying device type
  49866. * @param deviceSlot "Slot" or index that device is referenced in
  49867. */
  49868. private _removeDevice;
  49869. /**
  49870. * Updates array storing first connected device of each type
  49871. * @param type Type of Device
  49872. */
  49873. private _updateFirstDevices;
  49874. }
  49875. }
  49876. declare module BABYLON {
  49877. /**
  49878. * Options to create the null engine
  49879. */
  49880. export class NullEngineOptions {
  49881. /**
  49882. * Render width (Default: 512)
  49883. */
  49884. renderWidth: number;
  49885. /**
  49886. * Render height (Default: 256)
  49887. */
  49888. renderHeight: number;
  49889. /**
  49890. * Texture size (Default: 512)
  49891. */
  49892. textureSize: number;
  49893. /**
  49894. * If delta time between frames should be constant
  49895. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  49896. */
  49897. deterministicLockstep: boolean;
  49898. /**
  49899. * Maximum about of steps between frames (Default: 4)
  49900. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  49901. */
  49902. lockstepMaxSteps: number;
  49903. }
  49904. /**
  49905. * The null engine class provides support for headless version of babylon.js.
  49906. * This can be used in server side scenario or for testing purposes
  49907. */
  49908. export class NullEngine extends Engine {
  49909. private _options;
  49910. /**
  49911. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  49912. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  49913. * @returns true if engine is in deterministic lock step mode
  49914. */
  49915. isDeterministicLockStep(): boolean;
  49916. /**
  49917. * Gets the max steps when engine is running in deterministic lock step
  49918. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  49919. * @returns the max steps
  49920. */
  49921. getLockstepMaxSteps(): number;
  49922. /**
  49923. * Gets the current hardware scaling level.
  49924. * By default the hardware scaling level is computed from the window device ratio.
  49925. * 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.
  49926. * @returns a number indicating the current hardware scaling level
  49927. */
  49928. getHardwareScalingLevel(): number;
  49929. constructor(options?: NullEngineOptions);
  49930. /**
  49931. * Creates a vertex buffer
  49932. * @param vertices the data for the vertex buffer
  49933. * @returns the new WebGL static buffer
  49934. */
  49935. createVertexBuffer(vertices: FloatArray): DataBuffer;
  49936. /**
  49937. * Creates a new index buffer
  49938. * @param indices defines the content of the index buffer
  49939. * @param updatable defines if the index buffer must be updatable
  49940. * @returns a new webGL buffer
  49941. */
  49942. createIndexBuffer(indices: IndicesArray): DataBuffer;
  49943. /**
  49944. * Clear the current render buffer or the current render target (if any is set up)
  49945. * @param color defines the color to use
  49946. * @param backBuffer defines if the back buffer must be cleared
  49947. * @param depth defines if the depth buffer must be cleared
  49948. * @param stencil defines if the stencil buffer must be cleared
  49949. */
  49950. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  49951. /**
  49952. * Gets the current render width
  49953. * @param useScreen defines if screen size must be used (or the current render target if any)
  49954. * @returns a number defining the current render width
  49955. */
  49956. getRenderWidth(useScreen?: boolean): number;
  49957. /**
  49958. * Gets the current render height
  49959. * @param useScreen defines if screen size must be used (or the current render target if any)
  49960. * @returns a number defining the current render height
  49961. */
  49962. getRenderHeight(useScreen?: boolean): number;
  49963. /**
  49964. * Set the WebGL's viewport
  49965. * @param viewport defines the viewport element to be used
  49966. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  49967. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  49968. */
  49969. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  49970. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  49971. /**
  49972. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  49973. * @param pipelineContext defines the pipeline context to use
  49974. * @param uniformsNames defines the list of uniform names
  49975. * @returns an array of webGL uniform locations
  49976. */
  49977. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  49978. /**
  49979. * Gets the lsit of active attributes for a given webGL program
  49980. * @param pipelineContext defines the pipeline context to use
  49981. * @param attributesNames defines the list of attribute names to get
  49982. * @returns an array of indices indicating the offset of each attribute
  49983. */
  49984. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  49985. /**
  49986. * Binds an effect to the webGL context
  49987. * @param effect defines the effect to bind
  49988. */
  49989. bindSamplers(effect: Effect): void;
  49990. /**
  49991. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  49992. * @param effect defines the effect to activate
  49993. */
  49994. enableEffect(effect: Effect): void;
  49995. /**
  49996. * Set various states to the webGL context
  49997. * @param culling defines backface culling state
  49998. * @param zOffset defines the value to apply to zOffset (0 by default)
  49999. * @param force defines if states must be applied even if cache is up to date
  50000. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  50001. */
  50002. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  50003. /**
  50004. * Set the value of an uniform to an array of int32
  50005. * @param uniform defines the webGL uniform location where to store the value
  50006. * @param array defines the array of int32 to store
  50007. */
  50008. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  50009. /**
  50010. * Set the value of an uniform to an array of int32 (stored as vec2)
  50011. * @param uniform defines the webGL uniform location where to store the value
  50012. * @param array defines the array of int32 to store
  50013. */
  50014. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  50015. /**
  50016. * Set the value of an uniform to an array of int32 (stored as vec3)
  50017. * @param uniform defines the webGL uniform location where to store the value
  50018. * @param array defines the array of int32 to store
  50019. */
  50020. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  50021. /**
  50022. * Set the value of an uniform to an array of int32 (stored as vec4)
  50023. * @param uniform defines the webGL uniform location where to store the value
  50024. * @param array defines the array of int32 to store
  50025. */
  50026. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  50027. /**
  50028. * Set the value of an uniform to an array of float32
  50029. * @param uniform defines the webGL uniform location where to store the value
  50030. * @param array defines the array of float32 to store
  50031. */
  50032. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  50033. /**
  50034. * Set the value of an uniform to an array of float32 (stored as vec2)
  50035. * @param uniform defines the webGL uniform location where to store the value
  50036. * @param array defines the array of float32 to store
  50037. */
  50038. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  50039. /**
  50040. * Set the value of an uniform to an array of float32 (stored as vec3)
  50041. * @param uniform defines the webGL uniform location where to store the value
  50042. * @param array defines the array of float32 to store
  50043. */
  50044. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  50045. /**
  50046. * Set the value of an uniform to an array of float32 (stored as vec4)
  50047. * @param uniform defines the webGL uniform location where to store the value
  50048. * @param array defines the array of float32 to store
  50049. */
  50050. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  50051. /**
  50052. * Set the value of an uniform to an array of number
  50053. * @param uniform defines the webGL uniform location where to store the value
  50054. * @param array defines the array of number to store
  50055. */
  50056. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  50057. /**
  50058. * Set the value of an uniform to an array of number (stored as vec2)
  50059. * @param uniform defines the webGL uniform location where to store the value
  50060. * @param array defines the array of number to store
  50061. */
  50062. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  50063. /**
  50064. * Set the value of an uniform to an array of number (stored as vec3)
  50065. * @param uniform defines the webGL uniform location where to store the value
  50066. * @param array defines the array of number to store
  50067. */
  50068. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  50069. /**
  50070. * Set the value of an uniform to an array of number (stored as vec4)
  50071. * @param uniform defines the webGL uniform location where to store the value
  50072. * @param array defines the array of number to store
  50073. */
  50074. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  50075. /**
  50076. * Set the value of an uniform to an array of float32 (stored as matrices)
  50077. * @param uniform defines the webGL uniform location where to store the value
  50078. * @param matrices defines the array of float32 to store
  50079. */
  50080. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  50081. /**
  50082. * Set the value of an uniform to a matrix (3x3)
  50083. * @param uniform defines the webGL uniform location where to store the value
  50084. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  50085. */
  50086. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50087. /**
  50088. * Set the value of an uniform to a matrix (2x2)
  50089. * @param uniform defines the webGL uniform location where to store the value
  50090. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  50091. */
  50092. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50093. /**
  50094. * Set the value of an uniform to a number (float)
  50095. * @param uniform defines the webGL uniform location where to store the value
  50096. * @param value defines the float number to store
  50097. */
  50098. setFloat(uniform: WebGLUniformLocation, value: number): void;
  50099. /**
  50100. * Set the value of an uniform to a vec2
  50101. * @param uniform defines the webGL uniform location where to store the value
  50102. * @param x defines the 1st component of the value
  50103. * @param y defines the 2nd component of the value
  50104. */
  50105. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  50106. /**
  50107. * Set the value of an uniform to a vec3
  50108. * @param uniform defines the webGL uniform location where to store the value
  50109. * @param x defines the 1st component of the value
  50110. * @param y defines the 2nd component of the value
  50111. * @param z defines the 3rd component of the value
  50112. */
  50113. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  50114. /**
  50115. * Set the value of an uniform to a boolean
  50116. * @param uniform defines the webGL uniform location where to store the value
  50117. * @param bool defines the boolean to store
  50118. */
  50119. setBool(uniform: WebGLUniformLocation, bool: number): void;
  50120. /**
  50121. * Set the value of an uniform to a vec4
  50122. * @param uniform defines the webGL uniform location where to store the value
  50123. * @param x defines the 1st component of the value
  50124. * @param y defines the 2nd component of the value
  50125. * @param z defines the 3rd component of the value
  50126. * @param w defines the 4th component of the value
  50127. */
  50128. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  50129. /**
  50130. * Sets the current alpha mode
  50131. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  50132. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  50133. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  50134. */
  50135. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  50136. /**
  50137. * Bind webGl buffers directly to the webGL context
  50138. * @param vertexBuffers defines the vertex buffer to bind
  50139. * @param indexBuffer defines the index buffer to bind
  50140. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  50141. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  50142. * @param effect defines the effect associated with the vertex buffer
  50143. */
  50144. bindBuffers(vertexBuffers: {
  50145. [key: string]: VertexBuffer;
  50146. }, indexBuffer: DataBuffer, effect: Effect): void;
  50147. /**
  50148. * Force the entire cache to be cleared
  50149. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  50150. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  50151. */
  50152. wipeCaches(bruteForce?: boolean): void;
  50153. /**
  50154. * Send a draw order
  50155. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  50156. * @param indexStart defines the starting index
  50157. * @param indexCount defines the number of index to draw
  50158. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50159. */
  50160. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  50161. /**
  50162. * Draw a list of indexed primitives
  50163. * @param fillMode defines the primitive to use
  50164. * @param indexStart defines the starting index
  50165. * @param indexCount defines the number of index to draw
  50166. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50167. */
  50168. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  50169. /**
  50170. * Draw a list of unindexed primitives
  50171. * @param fillMode defines the primitive to use
  50172. * @param verticesStart defines the index of first vertex to draw
  50173. * @param verticesCount defines the count of vertices to draw
  50174. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50175. */
  50176. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  50177. /** @hidden */
  50178. _createTexture(): WebGLTexture;
  50179. /** @hidden */
  50180. _releaseTexture(texture: InternalTexture): void;
  50181. /**
  50182. * Usually called from Texture.ts.
  50183. * Passed information to create a WebGLTexture
  50184. * @param urlArg defines a value which contains one of the following:
  50185. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  50186. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  50187. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  50188. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  50189. * @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)
  50190. * @param scene needed for loading to the correct scene
  50191. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  50192. * @param onLoad optional callback to be called upon successful completion
  50193. * @param onError optional callback to be called upon failure
  50194. * @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
  50195. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  50196. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  50197. * @param forcedExtension defines the extension to use to pick the right loader
  50198. * @param mimeType defines an optional mime type
  50199. * @returns a InternalTexture for assignment back into BABYLON.Texture
  50200. */
  50201. 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;
  50202. /**
  50203. * Creates a new render target texture
  50204. * @param size defines the size of the texture
  50205. * @param options defines the options used to create the texture
  50206. * @returns a new render target texture stored in an InternalTexture
  50207. */
  50208. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  50209. /**
  50210. * Update the sampling mode of a given texture
  50211. * @param samplingMode defines the required sampling mode
  50212. * @param texture defines the texture to update
  50213. */
  50214. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  50215. /**
  50216. * Binds the frame buffer to the specified texture.
  50217. * @param texture The texture to render to or null for the default canvas
  50218. * @param faceIndex The face of the texture to render to in case of cube texture
  50219. * @param requiredWidth The width of the target to render to
  50220. * @param requiredHeight The height of the target to render to
  50221. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  50222. * @param lodLevel defines le lod level to bind to the frame buffer
  50223. */
  50224. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  50225. /**
  50226. * Unbind the current render target texture from the webGL context
  50227. * @param texture defines the render target texture to unbind
  50228. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  50229. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  50230. */
  50231. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  50232. /**
  50233. * Creates a dynamic vertex buffer
  50234. * @param vertices the data for the dynamic vertex buffer
  50235. * @returns the new WebGL dynamic buffer
  50236. */
  50237. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  50238. /**
  50239. * Update the content of a dynamic texture
  50240. * @param texture defines the texture to update
  50241. * @param canvas defines the canvas containing the source
  50242. * @param invertY defines if data must be stored with Y axis inverted
  50243. * @param premulAlpha defines if alpha is stored as premultiplied
  50244. * @param format defines the format of the data
  50245. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  50246. */
  50247. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  50248. /**
  50249. * Gets a boolean indicating if all created effects are ready
  50250. * @returns true if all effects are ready
  50251. */
  50252. areAllEffectsReady(): boolean;
  50253. /**
  50254. * @hidden
  50255. * Get the current error code of the webGL context
  50256. * @returns the error code
  50257. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  50258. */
  50259. getError(): number;
  50260. /** @hidden */
  50261. _getUnpackAlignement(): number;
  50262. /** @hidden */
  50263. _unpackFlipY(value: boolean): void;
  50264. /**
  50265. * Update a dynamic index buffer
  50266. * @param indexBuffer defines the target index buffer
  50267. * @param indices defines the data to update
  50268. * @param offset defines the offset in the target index buffer where update should start
  50269. */
  50270. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  50271. /**
  50272. * Updates a dynamic vertex buffer.
  50273. * @param vertexBuffer the vertex buffer to update
  50274. * @param vertices the data used to update the vertex buffer
  50275. * @param byteOffset the byte offset of the data (optional)
  50276. * @param byteLength the byte length of the data (optional)
  50277. */
  50278. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  50279. /** @hidden */
  50280. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  50281. /** @hidden */
  50282. _bindTexture(channel: number, texture: InternalTexture): void;
  50283. protected _deleteBuffer(buffer: WebGLBuffer): void;
  50284. /**
  50285. * 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
  50286. */
  50287. releaseEffects(): void;
  50288. displayLoadingUI(): void;
  50289. hideLoadingUI(): void;
  50290. /** @hidden */
  50291. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50292. /** @hidden */
  50293. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50294. /** @hidden */
  50295. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50296. /** @hidden */
  50297. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  50298. }
  50299. }
  50300. declare module BABYLON {
  50301. /**
  50302. * @hidden
  50303. **/
  50304. export class _TimeToken {
  50305. _startTimeQuery: Nullable<WebGLQuery>;
  50306. _endTimeQuery: Nullable<WebGLQuery>;
  50307. _timeElapsedQuery: Nullable<WebGLQuery>;
  50308. _timeElapsedQueryEnded: boolean;
  50309. }
  50310. }
  50311. declare module BABYLON {
  50312. /** @hidden */
  50313. export class _OcclusionDataStorage {
  50314. /** @hidden */
  50315. occlusionInternalRetryCounter: number;
  50316. /** @hidden */
  50317. isOcclusionQueryInProgress: boolean;
  50318. /** @hidden */
  50319. isOccluded: boolean;
  50320. /** @hidden */
  50321. occlusionRetryCount: number;
  50322. /** @hidden */
  50323. occlusionType: number;
  50324. /** @hidden */
  50325. occlusionQueryAlgorithmType: number;
  50326. }
  50327. interface Engine {
  50328. /**
  50329. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  50330. * @return the new query
  50331. */
  50332. createQuery(): WebGLQuery;
  50333. /**
  50334. * Delete and release a webGL query
  50335. * @param query defines the query to delete
  50336. * @return the current engine
  50337. */
  50338. deleteQuery(query: WebGLQuery): Engine;
  50339. /**
  50340. * Check if a given query has resolved and got its value
  50341. * @param query defines the query to check
  50342. * @returns true if the query got its value
  50343. */
  50344. isQueryResultAvailable(query: WebGLQuery): boolean;
  50345. /**
  50346. * Gets the value of a given query
  50347. * @param query defines the query to check
  50348. * @returns the value of the query
  50349. */
  50350. getQueryResult(query: WebGLQuery): number;
  50351. /**
  50352. * Initiates an occlusion query
  50353. * @param algorithmType defines the algorithm to use
  50354. * @param query defines the query to use
  50355. * @returns the current engine
  50356. * @see http://doc.babylonjs.com/features/occlusionquery
  50357. */
  50358. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  50359. /**
  50360. * Ends an occlusion query
  50361. * @see http://doc.babylonjs.com/features/occlusionquery
  50362. * @param algorithmType defines the algorithm to use
  50363. * @returns the current engine
  50364. */
  50365. endOcclusionQuery(algorithmType: number): Engine;
  50366. /**
  50367. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  50368. * Please note that only one query can be issued at a time
  50369. * @returns a time token used to track the time span
  50370. */
  50371. startTimeQuery(): Nullable<_TimeToken>;
  50372. /**
  50373. * Ends a time query
  50374. * @param token defines the token used to measure the time span
  50375. * @returns the time spent (in ns)
  50376. */
  50377. endTimeQuery(token: _TimeToken): int;
  50378. /** @hidden */
  50379. _currentNonTimestampToken: Nullable<_TimeToken>;
  50380. /** @hidden */
  50381. _createTimeQuery(): WebGLQuery;
  50382. /** @hidden */
  50383. _deleteTimeQuery(query: WebGLQuery): void;
  50384. /** @hidden */
  50385. _getGlAlgorithmType(algorithmType: number): number;
  50386. /** @hidden */
  50387. _getTimeQueryResult(query: WebGLQuery): any;
  50388. /** @hidden */
  50389. _getTimeQueryAvailability(query: WebGLQuery): any;
  50390. }
  50391. interface AbstractMesh {
  50392. /**
  50393. * Backing filed
  50394. * @hidden
  50395. */
  50396. __occlusionDataStorage: _OcclusionDataStorage;
  50397. /**
  50398. * Access property
  50399. * @hidden
  50400. */
  50401. _occlusionDataStorage: _OcclusionDataStorage;
  50402. /**
  50403. * 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.
  50404. * The default value is -1 which means don't break the query and wait till the result
  50405. * @see http://doc.babylonjs.com/features/occlusionquery
  50406. */
  50407. occlusionRetryCount: number;
  50408. /**
  50409. * 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:
  50410. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  50411. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  50412. * * 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.
  50413. * @see http://doc.babylonjs.com/features/occlusionquery
  50414. */
  50415. occlusionType: number;
  50416. /**
  50417. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  50418. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  50419. * * 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.
  50420. * @see http://doc.babylonjs.com/features/occlusionquery
  50421. */
  50422. occlusionQueryAlgorithmType: number;
  50423. /**
  50424. * 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
  50425. * @see http://doc.babylonjs.com/features/occlusionquery
  50426. */
  50427. isOccluded: boolean;
  50428. /**
  50429. * Flag to check the progress status of the query
  50430. * @see http://doc.babylonjs.com/features/occlusionquery
  50431. */
  50432. isOcclusionQueryInProgress: boolean;
  50433. }
  50434. }
  50435. declare module BABYLON {
  50436. /** @hidden */
  50437. export var _forceTransformFeedbackToBundle: boolean;
  50438. interface Engine {
  50439. /**
  50440. * Creates a webGL transform feedback object
  50441. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  50442. * @returns the webGL transform feedback object
  50443. */
  50444. createTransformFeedback(): WebGLTransformFeedback;
  50445. /**
  50446. * Delete a webGL transform feedback object
  50447. * @param value defines the webGL transform feedback object to delete
  50448. */
  50449. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  50450. /**
  50451. * Bind a webGL transform feedback object to the webgl context
  50452. * @param value defines the webGL transform feedback object to bind
  50453. */
  50454. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  50455. /**
  50456. * Begins a transform feedback operation
  50457. * @param usePoints defines if points or triangles must be used
  50458. */
  50459. beginTransformFeedback(usePoints: boolean): void;
  50460. /**
  50461. * Ends a transform feedback operation
  50462. */
  50463. endTransformFeedback(): void;
  50464. /**
  50465. * Specify the varyings to use with transform feedback
  50466. * @param program defines the associated webGL program
  50467. * @param value defines the list of strings representing the varying names
  50468. */
  50469. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  50470. /**
  50471. * Bind a webGL buffer for a transform feedback operation
  50472. * @param value defines the webGL buffer to bind
  50473. */
  50474. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  50475. }
  50476. }
  50477. declare module BABYLON {
  50478. /**
  50479. * Creation options of the multi render target texture.
  50480. */
  50481. export interface IMultiRenderTargetOptions {
  50482. /**
  50483. * Define if the texture needs to create mip maps after render.
  50484. */
  50485. generateMipMaps?: boolean;
  50486. /**
  50487. * Define the types of all the draw buffers we want to create
  50488. */
  50489. types?: number[];
  50490. /**
  50491. * Define the sampling modes of all the draw buffers we want to create
  50492. */
  50493. samplingModes?: number[];
  50494. /**
  50495. * Define if a depth buffer is required
  50496. */
  50497. generateDepthBuffer?: boolean;
  50498. /**
  50499. * Define if a stencil buffer is required
  50500. */
  50501. generateStencilBuffer?: boolean;
  50502. /**
  50503. * Define if a depth texture is required instead of a depth buffer
  50504. */
  50505. generateDepthTexture?: boolean;
  50506. /**
  50507. * Define the number of desired draw buffers
  50508. */
  50509. textureCount?: number;
  50510. /**
  50511. * Define if aspect ratio should be adapted to the texture or stay the scene one
  50512. */
  50513. doNotChangeAspectRatio?: boolean;
  50514. /**
  50515. * Define the default type of the buffers we are creating
  50516. */
  50517. defaultType?: number;
  50518. }
  50519. /**
  50520. * A multi render target, like a render target provides the ability to render to a texture.
  50521. * Unlike the render target, it can render to several draw buffers in one draw.
  50522. * This is specially interesting in deferred rendering or for any effects requiring more than
  50523. * just one color from a single pass.
  50524. */
  50525. export class MultiRenderTarget extends RenderTargetTexture {
  50526. private _internalTextures;
  50527. private _textures;
  50528. private _multiRenderTargetOptions;
  50529. /**
  50530. * Get if draw buffers are currently supported by the used hardware and browser.
  50531. */
  50532. get isSupported(): boolean;
  50533. /**
  50534. * Get the list of textures generated by the multi render target.
  50535. */
  50536. get textures(): Texture[];
  50537. /**
  50538. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  50539. */
  50540. get depthTexture(): Texture;
  50541. /**
  50542. * Set the wrapping mode on U of all the textures we are rendering to.
  50543. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  50544. */
  50545. set wrapU(wrap: number);
  50546. /**
  50547. * Set the wrapping mode on V of all the textures we are rendering to.
  50548. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  50549. */
  50550. set wrapV(wrap: number);
  50551. /**
  50552. * Instantiate a new multi render target texture.
  50553. * A multi render target, like a render target provides the ability to render to a texture.
  50554. * Unlike the render target, it can render to several draw buffers in one draw.
  50555. * This is specially interesting in deferred rendering or for any effects requiring more than
  50556. * just one color from a single pass.
  50557. * @param name Define the name of the texture
  50558. * @param size Define the size of the buffers to render to
  50559. * @param count Define the number of target we are rendering into
  50560. * @param scene Define the scene the texture belongs to
  50561. * @param options Define the options used to create the multi render target
  50562. */
  50563. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  50564. /** @hidden */
  50565. _rebuild(): void;
  50566. private _createInternalTextures;
  50567. private _createTextures;
  50568. /**
  50569. * Define the number of samples used if MSAA is enabled.
  50570. */
  50571. get samples(): number;
  50572. set samples(value: number);
  50573. /**
  50574. * Resize all the textures in the multi render target.
  50575. * Be carrefull as it will recreate all the data in the new texture.
  50576. * @param size Define the new size
  50577. */
  50578. resize(size: any): void;
  50579. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  50580. /**
  50581. * Dispose the render targets and their associated resources
  50582. */
  50583. dispose(): void;
  50584. /**
  50585. * Release all the underlying texture used as draw buffers.
  50586. */
  50587. releaseInternalTextures(): void;
  50588. }
  50589. }
  50590. declare module BABYLON {
  50591. interface ThinEngine {
  50592. /**
  50593. * Unbind a list of render target textures from the webGL context
  50594. * This is used only when drawBuffer extension or webGL2 are active
  50595. * @param textures defines the render target textures to unbind
  50596. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  50597. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  50598. */
  50599. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  50600. /**
  50601. * Create a multi render target texture
  50602. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  50603. * @param size defines the size of the texture
  50604. * @param options defines the creation options
  50605. * @returns the cube texture as an InternalTexture
  50606. */
  50607. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  50608. /**
  50609. * Update the sample count for a given multiple render target texture
  50610. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  50611. * @param textures defines the textures to update
  50612. * @param samples defines the sample count to set
  50613. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  50614. */
  50615. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  50616. }
  50617. }
  50618. declare module BABYLON {
  50619. /**
  50620. * Class used to define an additional view for the engine
  50621. * @see https://doc.babylonjs.com/how_to/multi_canvases
  50622. */
  50623. export class EngineView {
  50624. /** Defines the canvas where to render the view */
  50625. target: HTMLCanvasElement;
  50626. /** Defines an optional camera used to render the view (will use active camera else) */
  50627. camera?: Camera;
  50628. }
  50629. interface Engine {
  50630. /**
  50631. * Gets or sets the HTML element to use for attaching events
  50632. */
  50633. inputElement: Nullable<HTMLElement>;
  50634. /**
  50635. * Gets the current engine view
  50636. * @see https://doc.babylonjs.com/how_to/multi_canvases
  50637. */
  50638. activeView: Nullable<EngineView>;
  50639. /** Gets or sets the list of views */
  50640. views: EngineView[];
  50641. /**
  50642. * Register a new child canvas
  50643. * @param canvas defines the canvas to register
  50644. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  50645. * @returns the associated view
  50646. */
  50647. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  50648. /**
  50649. * Remove a registered child canvas
  50650. * @param canvas defines the canvas to remove
  50651. * @returns the current engine
  50652. */
  50653. unRegisterView(canvas: HTMLCanvasElement): Engine;
  50654. }
  50655. }
  50656. declare module BABYLON {
  50657. interface Engine {
  50658. /** @hidden */
  50659. _excludedCompressedTextures: string[];
  50660. /** @hidden */
  50661. _textureFormatInUse: string;
  50662. /**
  50663. * Gets the list of texture formats supported
  50664. */
  50665. readonly texturesSupported: Array<string>;
  50666. /**
  50667. * Gets the texture format in use
  50668. */
  50669. readonly textureFormatInUse: Nullable<string>;
  50670. /**
  50671. * Set the compressed texture extensions or file names to skip.
  50672. *
  50673. * @param skippedFiles defines the list of those texture files you want to skip
  50674. * Example: [".dds", ".env", "myfile.png"]
  50675. */
  50676. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  50677. /**
  50678. * Set the compressed texture format to use, based on the formats you have, and the formats
  50679. * supported by the hardware / browser.
  50680. *
  50681. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  50682. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  50683. * to API arguments needed to compressed textures. This puts the burden on the container
  50684. * generator to house the arcane code for determining these for current & future formats.
  50685. *
  50686. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  50687. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  50688. *
  50689. * Note: The result of this call is not taken into account when a texture is base64.
  50690. *
  50691. * @param formatsAvailable defines the list of those format families you have created
  50692. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  50693. *
  50694. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  50695. * @returns The extension selected.
  50696. */
  50697. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  50698. }
  50699. }
  50700. declare module BABYLON {
  50701. /**
  50702. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  50703. */
  50704. export interface CubeMapInfo {
  50705. /**
  50706. * The pixel array for the front face.
  50707. * This is stored in format, left to right, up to down format.
  50708. */
  50709. front: Nullable<ArrayBufferView>;
  50710. /**
  50711. * The pixel array for the back face.
  50712. * This is stored in format, left to right, up to down format.
  50713. */
  50714. back: Nullable<ArrayBufferView>;
  50715. /**
  50716. * The pixel array for the left face.
  50717. * This is stored in format, left to right, up to down format.
  50718. */
  50719. left: Nullable<ArrayBufferView>;
  50720. /**
  50721. * The pixel array for the right face.
  50722. * This is stored in format, left to right, up to down format.
  50723. */
  50724. right: Nullable<ArrayBufferView>;
  50725. /**
  50726. * The pixel array for the up face.
  50727. * This is stored in format, left to right, up to down format.
  50728. */
  50729. up: Nullable<ArrayBufferView>;
  50730. /**
  50731. * The pixel array for the down face.
  50732. * This is stored in format, left to right, up to down format.
  50733. */
  50734. down: Nullable<ArrayBufferView>;
  50735. /**
  50736. * The size of the cubemap stored.
  50737. *
  50738. * Each faces will be size * size pixels.
  50739. */
  50740. size: number;
  50741. /**
  50742. * The format of the texture.
  50743. *
  50744. * RGBA, RGB.
  50745. */
  50746. format: number;
  50747. /**
  50748. * The type of the texture data.
  50749. *
  50750. * UNSIGNED_INT, FLOAT.
  50751. */
  50752. type: number;
  50753. /**
  50754. * Specifies whether the texture is in gamma space.
  50755. */
  50756. gammaSpace: boolean;
  50757. }
  50758. /**
  50759. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  50760. */
  50761. export class PanoramaToCubeMapTools {
  50762. private static FACE_LEFT;
  50763. private static FACE_RIGHT;
  50764. private static FACE_FRONT;
  50765. private static FACE_BACK;
  50766. private static FACE_DOWN;
  50767. private static FACE_UP;
  50768. /**
  50769. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  50770. *
  50771. * @param float32Array The source data.
  50772. * @param inputWidth The width of the input panorama.
  50773. * @param inputHeight The height of the input panorama.
  50774. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  50775. * @return The cubemap data
  50776. */
  50777. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  50778. private static CreateCubemapTexture;
  50779. private static CalcProjectionSpherical;
  50780. }
  50781. }
  50782. declare module BABYLON {
  50783. /**
  50784. * Helper class dealing with the extraction of spherical polynomial dataArray
  50785. * from a cube map.
  50786. */
  50787. export class CubeMapToSphericalPolynomialTools {
  50788. private static FileFaces;
  50789. /**
  50790. * Converts a texture to the according Spherical Polynomial data.
  50791. * This extracts the first 3 orders only as they are the only one used in the lighting.
  50792. *
  50793. * @param texture The texture to extract the information from.
  50794. * @return The Spherical Polynomial data.
  50795. */
  50796. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  50797. /**
  50798. * Converts a cubemap to the according Spherical Polynomial data.
  50799. * This extracts the first 3 orders only as they are the only one used in the lighting.
  50800. *
  50801. * @param cubeInfo The Cube map to extract the information from.
  50802. * @return The Spherical Polynomial data.
  50803. */
  50804. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  50805. }
  50806. }
  50807. declare module BABYLON {
  50808. interface BaseTexture {
  50809. /**
  50810. * Get the polynomial representation of the texture data.
  50811. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  50812. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  50813. */
  50814. sphericalPolynomial: Nullable<SphericalPolynomial>;
  50815. }
  50816. }
  50817. declare module BABYLON {
  50818. /** @hidden */
  50819. export var rgbdEncodePixelShader: {
  50820. name: string;
  50821. shader: string;
  50822. };
  50823. }
  50824. declare module BABYLON {
  50825. /** @hidden */
  50826. export var rgbdDecodePixelShader: {
  50827. name: string;
  50828. shader: string;
  50829. };
  50830. }
  50831. declare module BABYLON {
  50832. /**
  50833. * Raw texture data and descriptor sufficient for WebGL texture upload
  50834. */
  50835. export interface EnvironmentTextureInfo {
  50836. /**
  50837. * Version of the environment map
  50838. */
  50839. version: number;
  50840. /**
  50841. * Width of image
  50842. */
  50843. width: number;
  50844. /**
  50845. * Irradiance information stored in the file.
  50846. */
  50847. irradiance: any;
  50848. /**
  50849. * Specular information stored in the file.
  50850. */
  50851. specular: any;
  50852. }
  50853. /**
  50854. * Defines One Image in the file. It requires only the position in the file
  50855. * as well as the length.
  50856. */
  50857. interface BufferImageData {
  50858. /**
  50859. * Length of the image data.
  50860. */
  50861. length: number;
  50862. /**
  50863. * Position of the data from the null terminator delimiting the end of the JSON.
  50864. */
  50865. position: number;
  50866. }
  50867. /**
  50868. * Defines the specular data enclosed in the file.
  50869. * This corresponds to the version 1 of the data.
  50870. */
  50871. export interface EnvironmentTextureSpecularInfoV1 {
  50872. /**
  50873. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  50874. */
  50875. specularDataPosition?: number;
  50876. /**
  50877. * This contains all the images data needed to reconstruct the cubemap.
  50878. */
  50879. mipmaps: Array<BufferImageData>;
  50880. /**
  50881. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  50882. */
  50883. lodGenerationScale: number;
  50884. }
  50885. /**
  50886. * Sets of helpers addressing the serialization and deserialization of environment texture
  50887. * stored in a BabylonJS env file.
  50888. * Those files are usually stored as .env files.
  50889. */
  50890. export class EnvironmentTextureTools {
  50891. /**
  50892. * Magic number identifying the env file.
  50893. */
  50894. private static _MagicBytes;
  50895. /**
  50896. * Gets the environment info from an env file.
  50897. * @param data The array buffer containing the .env bytes.
  50898. * @returns the environment file info (the json header) if successfully parsed.
  50899. */
  50900. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  50901. /**
  50902. * Creates an environment texture from a loaded cube texture.
  50903. * @param texture defines the cube texture to convert in env file
  50904. * @return a promise containing the environment data if succesfull.
  50905. */
  50906. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  50907. /**
  50908. * Creates a JSON representation of the spherical data.
  50909. * @param texture defines the texture containing the polynomials
  50910. * @return the JSON representation of the spherical info
  50911. */
  50912. private static _CreateEnvTextureIrradiance;
  50913. /**
  50914. * Creates the ArrayBufferViews used for initializing environment texture image data.
  50915. * @param data the image data
  50916. * @param info parameters that determine what views will be created for accessing the underlying buffer
  50917. * @return the views described by info providing access to the underlying buffer
  50918. */
  50919. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  50920. /**
  50921. * Uploads the texture info contained in the env file to the GPU.
  50922. * @param texture defines the internal texture to upload to
  50923. * @param data defines the data to load
  50924. * @param info defines the texture info retrieved through the GetEnvInfo method
  50925. * @returns a promise
  50926. */
  50927. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  50928. private static _OnImageReadyAsync;
  50929. /**
  50930. * Uploads the levels of image data to the GPU.
  50931. * @param texture defines the internal texture to upload to
  50932. * @param imageData defines the array buffer views of image data [mipmap][face]
  50933. * @returns a promise
  50934. */
  50935. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  50936. /**
  50937. * Uploads spherical polynomials information to the texture.
  50938. * @param texture defines the texture we are trying to upload the information to
  50939. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  50940. */
  50941. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  50942. /** @hidden */
  50943. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  50944. }
  50945. }
  50946. declare module BABYLON {
  50947. /** @hidden */
  50948. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  50949. private _genericAttributeLocation;
  50950. private _varyingLocationCount;
  50951. private _varyingLocationMap;
  50952. private _replacements;
  50953. private _textureCount;
  50954. private _uniforms;
  50955. lineProcessor(line: string): string;
  50956. attributeProcessor(attribute: string): string;
  50957. varyingProcessor(varying: string, isFragment: boolean): string;
  50958. uniformProcessor(uniform: string): string;
  50959. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  50960. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  50961. }
  50962. }
  50963. declare module BABYLON {
  50964. /**
  50965. * Container for accessors for natively-stored mesh data buffers.
  50966. */
  50967. class NativeDataBuffer extends DataBuffer {
  50968. /**
  50969. * Accessor value used to identify/retrieve a natively-stored index buffer.
  50970. */
  50971. nativeIndexBuffer?: any;
  50972. /**
  50973. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  50974. */
  50975. nativeVertexBuffer?: any;
  50976. }
  50977. /** @hidden */
  50978. class NativeTexture extends InternalTexture {
  50979. getInternalTexture(): InternalTexture;
  50980. getViewCount(): number;
  50981. }
  50982. /** @hidden */
  50983. export class NativeEngine extends Engine {
  50984. private readonly _native;
  50985. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  50986. private readonly INVALID_HANDLE;
  50987. getHardwareScalingLevel(): number;
  50988. constructor();
  50989. dispose(): void;
  50990. /**
  50991. * Can be used to override the current requestAnimationFrame requester.
  50992. * @hidden
  50993. */
  50994. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  50995. /**
  50996. * Override default engine behavior.
  50997. * @param color
  50998. * @param backBuffer
  50999. * @param depth
  51000. * @param stencil
  51001. */
  51002. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  51003. /**
  51004. * Gets host document
  51005. * @returns the host document object
  51006. */
  51007. getHostDocument(): Nullable<Document>;
  51008. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51009. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  51010. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  51011. recordVertexArrayObject(vertexBuffers: {
  51012. [key: string]: VertexBuffer;
  51013. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  51014. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51015. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51016. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  51017. /**
  51018. * Draw a list of indexed primitives
  51019. * @param fillMode defines the primitive to use
  51020. * @param indexStart defines the starting index
  51021. * @param indexCount defines the number of index to draw
  51022. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51023. */
  51024. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  51025. /**
  51026. * Draw a list of unindexed primitives
  51027. * @param fillMode defines the primitive to use
  51028. * @param verticesStart defines the index of first vertex to draw
  51029. * @param verticesCount defines the count of vertices to draw
  51030. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51031. */
  51032. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  51033. createPipelineContext(): IPipelineContext;
  51034. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  51035. /** @hidden */
  51036. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  51037. /** @hidden */
  51038. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  51039. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51040. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51041. protected _setProgram(program: WebGLProgram): void;
  51042. _releaseEffect(effect: Effect): void;
  51043. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  51044. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  51045. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  51046. bindSamplers(effect: Effect): void;
  51047. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  51048. getRenderWidth(useScreen?: boolean): number;
  51049. getRenderHeight(useScreen?: boolean): number;
  51050. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  51051. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  51052. /**
  51053. * Set the z offset to apply to current rendering
  51054. * @param value defines the offset to apply
  51055. */
  51056. setZOffset(value: number): void;
  51057. /**
  51058. * Gets the current value of the zOffset
  51059. * @returns the current zOffset state
  51060. */
  51061. getZOffset(): number;
  51062. /**
  51063. * Enable or disable depth buffering
  51064. * @param enable defines the state to set
  51065. */
  51066. setDepthBuffer(enable: boolean): void;
  51067. /**
  51068. * Gets a boolean indicating if depth writing is enabled
  51069. * @returns the current depth writing state
  51070. */
  51071. getDepthWrite(): boolean;
  51072. /**
  51073. * Enable or disable depth writing
  51074. * @param enable defines the state to set
  51075. */
  51076. setDepthWrite(enable: boolean): void;
  51077. /**
  51078. * Enable or disable color writing
  51079. * @param enable defines the state to set
  51080. */
  51081. setColorWrite(enable: boolean): void;
  51082. /**
  51083. * Gets a boolean indicating if color writing is enabled
  51084. * @returns the current color writing state
  51085. */
  51086. getColorWrite(): boolean;
  51087. /**
  51088. * Sets alpha constants used by some alpha blending modes
  51089. * @param r defines the red component
  51090. * @param g defines the green component
  51091. * @param b defines the blue component
  51092. * @param a defines the alpha component
  51093. */
  51094. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  51095. /**
  51096. * Sets the current alpha mode
  51097. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  51098. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  51099. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51100. */
  51101. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  51102. /**
  51103. * Gets the current alpha mode
  51104. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51105. * @returns the current alpha mode
  51106. */
  51107. getAlphaMode(): number;
  51108. setInt(uniform: WebGLUniformLocation, int: number): void;
  51109. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  51110. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  51111. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  51112. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  51113. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  51114. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  51115. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  51116. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  51117. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  51118. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  51119. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  51120. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  51121. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  51122. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51123. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51124. setFloat(uniform: WebGLUniformLocation, value: number): void;
  51125. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  51126. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  51127. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  51128. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  51129. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  51130. wipeCaches(bruteForce?: boolean): void;
  51131. _createTexture(): WebGLTexture;
  51132. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  51133. /**
  51134. * Usually called from Texture.ts.
  51135. * Passed information to create a WebGLTexture
  51136. * @param url defines a value which contains one of the following:
  51137. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  51138. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  51139. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  51140. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  51141. * @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)
  51142. * @param scene needed for loading to the correct scene
  51143. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  51144. * @param onLoad optional callback to be called upon successful completion
  51145. * @param onError optional callback to be called upon failure
  51146. * @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
  51147. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  51148. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  51149. * @param forcedExtension defines the extension to use to pick the right loader
  51150. * @param mimeType defines an optional mime type
  51151. * @returns a InternalTexture for assignment back into BABYLON.Texture
  51152. */
  51153. 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;
  51154. /**
  51155. * Creates a cube texture
  51156. * @param rootUrl defines the url where the files to load is located
  51157. * @param scene defines the current scene
  51158. * @param files defines the list of files to load (1 per face)
  51159. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  51160. * @param onLoad defines an optional callback raised when the texture is loaded
  51161. * @param onError defines an optional callback raised if there is an issue to load the texture
  51162. * @param format defines the format of the data
  51163. * @param forcedExtension defines the extension to use to pick the right loader
  51164. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  51165. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51166. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51167. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  51168. * @returns the cube texture as an InternalTexture
  51169. */
  51170. 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;
  51171. private _getSamplingFilter;
  51172. private static _GetNativeTextureFormat;
  51173. createRenderTargetTexture(size: number | {
  51174. width: number;
  51175. height: number;
  51176. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  51177. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  51178. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  51179. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  51180. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  51181. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  51182. /**
  51183. * Updates a dynamic vertex buffer.
  51184. * @param vertexBuffer the vertex buffer to update
  51185. * @param data the data used to update the vertex buffer
  51186. * @param byteOffset the byte offset of the data (optional)
  51187. * @param byteLength the byte length of the data (optional)
  51188. */
  51189. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  51190. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  51191. private _updateAnisotropicLevel;
  51192. private _getAddressMode;
  51193. /** @hidden */
  51194. _bindTexture(channel: number, texture: InternalTexture): void;
  51195. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  51196. releaseEffects(): void;
  51197. /** @hidden */
  51198. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51199. /** @hidden */
  51200. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51201. /** @hidden */
  51202. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51203. /** @hidden */
  51204. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  51205. }
  51206. }
  51207. declare module BABYLON {
  51208. /**
  51209. * Gather the list of clipboard event types as constants.
  51210. */
  51211. export class ClipboardEventTypes {
  51212. /**
  51213. * The clipboard event is fired when a copy command is active (pressed).
  51214. */
  51215. static readonly COPY: number;
  51216. /**
  51217. * The clipboard event is fired when a cut command is active (pressed).
  51218. */
  51219. static readonly CUT: number;
  51220. /**
  51221. * The clipboard event is fired when a paste command is active (pressed).
  51222. */
  51223. static readonly PASTE: number;
  51224. }
  51225. /**
  51226. * This class is used to store clipboard related info for the onClipboardObservable event.
  51227. */
  51228. export class ClipboardInfo {
  51229. /**
  51230. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51231. */
  51232. type: number;
  51233. /**
  51234. * Defines the related dom event
  51235. */
  51236. event: ClipboardEvent;
  51237. /**
  51238. *Creates an instance of ClipboardInfo.
  51239. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  51240. * @param event Defines the related dom event
  51241. */
  51242. constructor(
  51243. /**
  51244. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51245. */
  51246. type: number,
  51247. /**
  51248. * Defines the related dom event
  51249. */
  51250. event: ClipboardEvent);
  51251. /**
  51252. * Get the clipboard event's type from the keycode.
  51253. * @param keyCode Defines the keyCode for the current keyboard event.
  51254. * @return {number}
  51255. */
  51256. static GetTypeFromCharacter(keyCode: number): number;
  51257. }
  51258. }
  51259. declare module BABYLON {
  51260. /**
  51261. * Google Daydream controller
  51262. */
  51263. export class DaydreamController extends WebVRController {
  51264. /**
  51265. * Base Url for the controller model.
  51266. */
  51267. static MODEL_BASE_URL: string;
  51268. /**
  51269. * File name for the controller model.
  51270. */
  51271. static MODEL_FILENAME: string;
  51272. /**
  51273. * Gamepad Id prefix used to identify Daydream Controller.
  51274. */
  51275. static readonly GAMEPAD_ID_PREFIX: string;
  51276. /**
  51277. * Creates a new DaydreamController from a gamepad
  51278. * @param vrGamepad the gamepad that the controller should be created from
  51279. */
  51280. constructor(vrGamepad: any);
  51281. /**
  51282. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51283. * @param scene scene in which to add meshes
  51284. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51285. */
  51286. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51287. /**
  51288. * Called once for each button that changed state since the last frame
  51289. * @param buttonIdx Which button index changed
  51290. * @param state New state of the button
  51291. * @param changes Which properties on the state changed since last frame
  51292. */
  51293. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51294. }
  51295. }
  51296. declare module BABYLON {
  51297. /**
  51298. * Gear VR Controller
  51299. */
  51300. export class GearVRController extends WebVRController {
  51301. /**
  51302. * Base Url for the controller model.
  51303. */
  51304. static MODEL_BASE_URL: string;
  51305. /**
  51306. * File name for the controller model.
  51307. */
  51308. static MODEL_FILENAME: string;
  51309. /**
  51310. * Gamepad Id prefix used to identify this controller.
  51311. */
  51312. static readonly GAMEPAD_ID_PREFIX: string;
  51313. private readonly _buttonIndexToObservableNameMap;
  51314. /**
  51315. * Creates a new GearVRController from a gamepad
  51316. * @param vrGamepad the gamepad that the controller should be created from
  51317. */
  51318. constructor(vrGamepad: any);
  51319. /**
  51320. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51321. * @param scene scene in which to add meshes
  51322. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51323. */
  51324. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51325. /**
  51326. * Called once for each button that changed state since the last frame
  51327. * @param buttonIdx Which button index changed
  51328. * @param state New state of the button
  51329. * @param changes Which properties on the state changed since last frame
  51330. */
  51331. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51332. }
  51333. }
  51334. declare module BABYLON {
  51335. /**
  51336. * Generic Controller
  51337. */
  51338. export class GenericController extends WebVRController {
  51339. /**
  51340. * Base Url for the controller model.
  51341. */
  51342. static readonly MODEL_BASE_URL: string;
  51343. /**
  51344. * File name for the controller model.
  51345. */
  51346. static readonly MODEL_FILENAME: string;
  51347. /**
  51348. * Creates a new GenericController from a gamepad
  51349. * @param vrGamepad the gamepad that the controller should be created from
  51350. */
  51351. constructor(vrGamepad: any);
  51352. /**
  51353. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51354. * @param scene scene in which to add meshes
  51355. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51356. */
  51357. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51358. /**
  51359. * Called once for each button that changed state since the last frame
  51360. * @param buttonIdx Which button index changed
  51361. * @param state New state of the button
  51362. * @param changes Which properties on the state changed since last frame
  51363. */
  51364. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51365. }
  51366. }
  51367. declare module BABYLON {
  51368. /**
  51369. * Oculus Touch Controller
  51370. */
  51371. export class OculusTouchController extends WebVRController {
  51372. /**
  51373. * Base Url for the controller model.
  51374. */
  51375. static MODEL_BASE_URL: string;
  51376. /**
  51377. * File name for the left controller model.
  51378. */
  51379. static MODEL_LEFT_FILENAME: string;
  51380. /**
  51381. * File name for the right controller model.
  51382. */
  51383. static MODEL_RIGHT_FILENAME: string;
  51384. /**
  51385. * Base Url for the Quest controller model.
  51386. */
  51387. static QUEST_MODEL_BASE_URL: string;
  51388. /**
  51389. * @hidden
  51390. * If the controllers are running on a device that needs the updated Quest controller models
  51391. */
  51392. static _IsQuest: boolean;
  51393. /**
  51394. * Fired when the secondary trigger on this controller is modified
  51395. */
  51396. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  51397. /**
  51398. * Fired when the thumb rest on this controller is modified
  51399. */
  51400. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  51401. /**
  51402. * Creates a new OculusTouchController from a gamepad
  51403. * @param vrGamepad the gamepad that the controller should be created from
  51404. */
  51405. constructor(vrGamepad: any);
  51406. /**
  51407. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51408. * @param scene scene in which to add meshes
  51409. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51410. */
  51411. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51412. /**
  51413. * Fired when the A button on this controller is modified
  51414. */
  51415. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51416. /**
  51417. * Fired when the B button on this controller is modified
  51418. */
  51419. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51420. /**
  51421. * Fired when the X button on this controller is modified
  51422. */
  51423. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51424. /**
  51425. * Fired when the Y button on this controller is modified
  51426. */
  51427. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51428. /**
  51429. * Called once for each button that changed state since the last frame
  51430. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  51431. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  51432. * 2) secondary trigger (same)
  51433. * 3) A (right) X (left), touch, pressed = value
  51434. * 4) B / Y
  51435. * 5) thumb rest
  51436. * @param buttonIdx Which button index changed
  51437. * @param state New state of the button
  51438. * @param changes Which properties on the state changed since last frame
  51439. */
  51440. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51441. }
  51442. }
  51443. declare module BABYLON {
  51444. /**
  51445. * Vive Controller
  51446. */
  51447. export class ViveController extends WebVRController {
  51448. /**
  51449. * Base Url for the controller model.
  51450. */
  51451. static MODEL_BASE_URL: string;
  51452. /**
  51453. * File name for the controller model.
  51454. */
  51455. static MODEL_FILENAME: string;
  51456. /**
  51457. * Creates a new ViveController from a gamepad
  51458. * @param vrGamepad the gamepad that the controller should be created from
  51459. */
  51460. constructor(vrGamepad: any);
  51461. /**
  51462. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51463. * @param scene scene in which to add meshes
  51464. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51465. */
  51466. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51467. /**
  51468. * Fired when the left button on this controller is modified
  51469. */
  51470. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51471. /**
  51472. * Fired when the right button on this controller is modified
  51473. */
  51474. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51475. /**
  51476. * Fired when the menu button on this controller is modified
  51477. */
  51478. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51479. /**
  51480. * Called once for each button that changed state since the last frame
  51481. * Vive mapping:
  51482. * 0: touchpad
  51483. * 1: trigger
  51484. * 2: left AND right buttons
  51485. * 3: menu button
  51486. * @param buttonIdx Which button index changed
  51487. * @param state New state of the button
  51488. * @param changes Which properties on the state changed since last frame
  51489. */
  51490. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51491. }
  51492. }
  51493. declare module BABYLON {
  51494. /**
  51495. * Defines the WindowsMotionController object that the state of the windows motion controller
  51496. */
  51497. export class WindowsMotionController extends WebVRController {
  51498. /**
  51499. * The base url used to load the left and right controller models
  51500. */
  51501. static MODEL_BASE_URL: string;
  51502. /**
  51503. * The name of the left controller model file
  51504. */
  51505. static MODEL_LEFT_FILENAME: string;
  51506. /**
  51507. * The name of the right controller model file
  51508. */
  51509. static MODEL_RIGHT_FILENAME: string;
  51510. /**
  51511. * The controller name prefix for this controller type
  51512. */
  51513. static readonly GAMEPAD_ID_PREFIX: string;
  51514. /**
  51515. * The controller id pattern for this controller type
  51516. */
  51517. private static readonly GAMEPAD_ID_PATTERN;
  51518. private _loadedMeshInfo;
  51519. protected readonly _mapping: {
  51520. buttons: string[];
  51521. buttonMeshNames: {
  51522. trigger: string;
  51523. menu: string;
  51524. grip: string;
  51525. thumbstick: string;
  51526. trackpad: string;
  51527. };
  51528. buttonObservableNames: {
  51529. trigger: string;
  51530. menu: string;
  51531. grip: string;
  51532. thumbstick: string;
  51533. trackpad: string;
  51534. };
  51535. axisMeshNames: string[];
  51536. pointingPoseMeshName: string;
  51537. };
  51538. /**
  51539. * Fired when the trackpad on this controller is clicked
  51540. */
  51541. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  51542. /**
  51543. * Fired when the trackpad on this controller is modified
  51544. */
  51545. onTrackpadValuesChangedObservable: Observable<StickValues>;
  51546. /**
  51547. * The current x and y values of this controller's trackpad
  51548. */
  51549. trackpad: StickValues;
  51550. /**
  51551. * Creates a new WindowsMotionController from a gamepad
  51552. * @param vrGamepad the gamepad that the controller should be created from
  51553. */
  51554. constructor(vrGamepad: any);
  51555. /**
  51556. * Fired when the trigger on this controller is modified
  51557. */
  51558. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51559. /**
  51560. * Fired when the menu button on this controller is modified
  51561. */
  51562. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51563. /**
  51564. * Fired when the grip button on this controller is modified
  51565. */
  51566. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51567. /**
  51568. * Fired when the thumbstick button on this controller is modified
  51569. */
  51570. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51571. /**
  51572. * Fired when the touchpad button on this controller is modified
  51573. */
  51574. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51575. /**
  51576. * Fired when the touchpad values on this controller are modified
  51577. */
  51578. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  51579. protected _updateTrackpad(): void;
  51580. /**
  51581. * Called once per frame by the engine.
  51582. */
  51583. update(): void;
  51584. /**
  51585. * Called once for each button that changed state since the last frame
  51586. * @param buttonIdx Which button index changed
  51587. * @param state New state of the button
  51588. * @param changes Which properties on the state changed since last frame
  51589. */
  51590. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51591. /**
  51592. * Moves the buttons on the controller mesh based on their current state
  51593. * @param buttonName the name of the button to move
  51594. * @param buttonValue the value of the button which determines the buttons new position
  51595. */
  51596. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  51597. /**
  51598. * Moves the axis on the controller mesh based on its current state
  51599. * @param axis the index of the axis
  51600. * @param axisValue the value of the axis which determines the meshes new position
  51601. * @hidden
  51602. */
  51603. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  51604. /**
  51605. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51606. * @param scene scene in which to add meshes
  51607. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51608. */
  51609. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  51610. /**
  51611. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  51612. * can be transformed by button presses and axes values, based on this._mapping.
  51613. *
  51614. * @param scene scene in which the meshes exist
  51615. * @param meshes list of meshes that make up the controller model to process
  51616. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  51617. */
  51618. private processModel;
  51619. private createMeshInfo;
  51620. /**
  51621. * Gets the ray of the controller in the direction the controller is pointing
  51622. * @param length the length the resulting ray should be
  51623. * @returns a ray in the direction the controller is pointing
  51624. */
  51625. getForwardRay(length?: number): Ray;
  51626. /**
  51627. * Disposes of the controller
  51628. */
  51629. dispose(): void;
  51630. }
  51631. /**
  51632. * This class represents a new windows motion controller in XR.
  51633. */
  51634. export class XRWindowsMotionController extends WindowsMotionController {
  51635. /**
  51636. * Changing the original WIndowsMotionController mapping to fir the new mapping
  51637. */
  51638. protected readonly _mapping: {
  51639. buttons: string[];
  51640. buttonMeshNames: {
  51641. trigger: string;
  51642. menu: string;
  51643. grip: string;
  51644. thumbstick: string;
  51645. trackpad: string;
  51646. };
  51647. buttonObservableNames: {
  51648. trigger: string;
  51649. menu: string;
  51650. grip: string;
  51651. thumbstick: string;
  51652. trackpad: string;
  51653. };
  51654. axisMeshNames: string[];
  51655. pointingPoseMeshName: string;
  51656. };
  51657. /**
  51658. * Construct a new XR-Based windows motion controller
  51659. *
  51660. * @param gamepadInfo the gamepad object from the browser
  51661. */
  51662. constructor(gamepadInfo: any);
  51663. /**
  51664. * holds the thumbstick values (X,Y)
  51665. */
  51666. thumbstickValues: StickValues;
  51667. /**
  51668. * Fired when the thumbstick on this controller is clicked
  51669. */
  51670. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  51671. /**
  51672. * Fired when the thumbstick on this controller is modified
  51673. */
  51674. onThumbstickValuesChangedObservable: Observable<StickValues>;
  51675. /**
  51676. * Fired when the touchpad button on this controller is modified
  51677. */
  51678. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  51679. /**
  51680. * Fired when the touchpad values on this controller are modified
  51681. */
  51682. onTrackpadValuesChangedObservable: Observable<StickValues>;
  51683. /**
  51684. * Fired when the thumbstick button on this controller is modified
  51685. * here to prevent breaking changes
  51686. */
  51687. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51688. /**
  51689. * updating the thumbstick(!) and not the trackpad.
  51690. * This is named this way due to the difference between WebVR and XR and to avoid
  51691. * changing the parent class.
  51692. */
  51693. protected _updateTrackpad(): void;
  51694. /**
  51695. * Disposes the class with joy
  51696. */
  51697. dispose(): void;
  51698. }
  51699. }
  51700. declare module BABYLON {
  51701. /**
  51702. * Class containing static functions to help procedurally build meshes
  51703. */
  51704. export class PolyhedronBuilder {
  51705. /**
  51706. * Creates a polyhedron mesh
  51707. * * 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
  51708. * * The parameter `size` (positive float, default 1) sets the polygon size
  51709. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  51710. * * 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`
  51711. * * 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
  51712. * * 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)`)
  51713. * * 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
  51714. * * 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
  51715. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51716. * * 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
  51717. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51718. * @param name defines the name of the mesh
  51719. * @param options defines the options used to create the mesh
  51720. * @param scene defines the hosting scene
  51721. * @returns the polyhedron mesh
  51722. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  51723. */
  51724. static CreatePolyhedron(name: string, options: {
  51725. type?: number;
  51726. size?: number;
  51727. sizeX?: number;
  51728. sizeY?: number;
  51729. sizeZ?: number;
  51730. custom?: any;
  51731. faceUV?: Vector4[];
  51732. faceColors?: Color4[];
  51733. flat?: boolean;
  51734. updatable?: boolean;
  51735. sideOrientation?: number;
  51736. frontUVs?: Vector4;
  51737. backUVs?: Vector4;
  51738. }, scene?: Nullable<Scene>): Mesh;
  51739. }
  51740. }
  51741. declare module BABYLON {
  51742. /**
  51743. * Gizmo that enables scaling a mesh along 3 axis
  51744. */
  51745. export class ScaleGizmo extends Gizmo {
  51746. /**
  51747. * Internal gizmo used for interactions on the x axis
  51748. */
  51749. xGizmo: AxisScaleGizmo;
  51750. /**
  51751. * Internal gizmo used for interactions on the y axis
  51752. */
  51753. yGizmo: AxisScaleGizmo;
  51754. /**
  51755. * Internal gizmo used for interactions on the z axis
  51756. */
  51757. zGizmo: AxisScaleGizmo;
  51758. /**
  51759. * Internal gizmo used to scale all axis equally
  51760. */
  51761. uniformScaleGizmo: AxisScaleGizmo;
  51762. private _meshAttached;
  51763. private _updateGizmoRotationToMatchAttachedMesh;
  51764. private _snapDistance;
  51765. private _scaleRatio;
  51766. private _uniformScalingMesh;
  51767. private _octahedron;
  51768. private _sensitivity;
  51769. /** Fires an event when any of it's sub gizmos are dragged */
  51770. onDragStartObservable: Observable<unknown>;
  51771. /** Fires an event when any of it's sub gizmos are released from dragging */
  51772. onDragEndObservable: Observable<unknown>;
  51773. get attachedMesh(): Nullable<AbstractMesh>;
  51774. set attachedMesh(mesh: Nullable<AbstractMesh>);
  51775. /**
  51776. * Creates a ScaleGizmo
  51777. * @param gizmoLayer The utility layer the gizmo will be added to
  51778. */
  51779. constructor(gizmoLayer?: UtilityLayerRenderer);
  51780. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  51781. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  51782. /**
  51783. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51784. */
  51785. set snapDistance(value: number);
  51786. get snapDistance(): number;
  51787. /**
  51788. * Ratio for the scale of the gizmo (Default: 1)
  51789. */
  51790. set scaleRatio(value: number);
  51791. get scaleRatio(): number;
  51792. /**
  51793. * Sensitivity factor for dragging (Default: 1)
  51794. */
  51795. set sensitivity(value: number);
  51796. get sensitivity(): number;
  51797. /**
  51798. * Disposes of the gizmo
  51799. */
  51800. dispose(): void;
  51801. }
  51802. }
  51803. declare module BABYLON {
  51804. /**
  51805. * Single axis scale gizmo
  51806. */
  51807. export class AxisScaleGizmo extends Gizmo {
  51808. /**
  51809. * Drag behavior responsible for the gizmos dragging interactions
  51810. */
  51811. dragBehavior: PointerDragBehavior;
  51812. private _pointerObserver;
  51813. /**
  51814. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51815. */
  51816. snapDistance: number;
  51817. /**
  51818. * Event that fires each time the gizmo snaps to a new location.
  51819. * * snapDistance is the the change in distance
  51820. */
  51821. onSnapObservable: Observable<{
  51822. snapDistance: number;
  51823. }>;
  51824. /**
  51825. * If the scaling operation should be done on all axis (default: false)
  51826. */
  51827. uniformScaling: boolean;
  51828. /**
  51829. * Custom sensitivity value for the drag strength
  51830. */
  51831. sensitivity: number;
  51832. private _isEnabled;
  51833. private _parent;
  51834. private _arrow;
  51835. private _coloredMaterial;
  51836. private _hoverMaterial;
  51837. /**
  51838. * Creates an AxisScaleGizmo
  51839. * @param gizmoLayer The utility layer the gizmo will be added to
  51840. * @param dragAxis The axis which the gizmo will be able to scale on
  51841. * @param color The color of the gizmo
  51842. */
  51843. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  51844. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51845. /**
  51846. * If the gizmo is enabled
  51847. */
  51848. set isEnabled(value: boolean);
  51849. get isEnabled(): boolean;
  51850. /**
  51851. * Disposes of the gizmo
  51852. */
  51853. dispose(): void;
  51854. /**
  51855. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  51856. * @param mesh The mesh to replace the default mesh of the gizmo
  51857. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  51858. */
  51859. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  51860. }
  51861. }
  51862. declare module BABYLON {
  51863. /**
  51864. * Bounding box gizmo
  51865. */
  51866. export class BoundingBoxGizmo extends Gizmo {
  51867. private _lineBoundingBox;
  51868. private _rotateSpheresParent;
  51869. private _scaleBoxesParent;
  51870. private _boundingDimensions;
  51871. private _renderObserver;
  51872. private _pointerObserver;
  51873. private _scaleDragSpeed;
  51874. private _tmpQuaternion;
  51875. private _tmpVector;
  51876. private _tmpRotationMatrix;
  51877. /**
  51878. * 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)
  51879. */
  51880. ignoreChildren: boolean;
  51881. /**
  51882. * 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)
  51883. */
  51884. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  51885. /**
  51886. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  51887. */
  51888. rotationSphereSize: number;
  51889. /**
  51890. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  51891. */
  51892. scaleBoxSize: number;
  51893. /**
  51894. * 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)
  51895. */
  51896. fixedDragMeshScreenSize: boolean;
  51897. /**
  51898. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  51899. */
  51900. fixedDragMeshScreenSizeDistanceFactor: number;
  51901. /**
  51902. * Fired when a rotation sphere or scale box is dragged
  51903. */
  51904. onDragStartObservable: Observable<{}>;
  51905. /**
  51906. * Fired when a scale box is dragged
  51907. */
  51908. onScaleBoxDragObservable: Observable<{}>;
  51909. /**
  51910. * Fired when a scale box drag is ended
  51911. */
  51912. onScaleBoxDragEndObservable: Observable<{}>;
  51913. /**
  51914. * Fired when a rotation sphere is dragged
  51915. */
  51916. onRotationSphereDragObservable: Observable<{}>;
  51917. /**
  51918. * Fired when a rotation sphere drag is ended
  51919. */
  51920. onRotationSphereDragEndObservable: Observable<{}>;
  51921. /**
  51922. * 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)
  51923. */
  51924. scalePivot: Nullable<Vector3>;
  51925. /**
  51926. * Mesh used as a pivot to rotate the attached mesh
  51927. */
  51928. private _anchorMesh;
  51929. private _existingMeshScale;
  51930. private _dragMesh;
  51931. private pointerDragBehavior;
  51932. private coloredMaterial;
  51933. private hoverColoredMaterial;
  51934. /**
  51935. * Sets the color of the bounding box gizmo
  51936. * @param color the color to set
  51937. */
  51938. setColor(color: Color3): void;
  51939. /**
  51940. * Creates an BoundingBoxGizmo
  51941. * @param gizmoLayer The utility layer the gizmo will be added to
  51942. * @param color The color of the gizmo
  51943. */
  51944. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  51945. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51946. private _selectNode;
  51947. /**
  51948. * Updates the bounding box information for the Gizmo
  51949. */
  51950. updateBoundingBox(): void;
  51951. private _updateRotationSpheres;
  51952. private _updateScaleBoxes;
  51953. /**
  51954. * Enables rotation on the specified axis and disables rotation on the others
  51955. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  51956. */
  51957. setEnabledRotationAxis(axis: string): void;
  51958. /**
  51959. * Enables/disables scaling
  51960. * @param enable if scaling should be enabled
  51961. * @param homogeneousScaling defines if scaling should only be homogeneous
  51962. */
  51963. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  51964. private _updateDummy;
  51965. /**
  51966. * Enables a pointer drag behavior on the bounding box of the gizmo
  51967. */
  51968. enableDragBehavior(): void;
  51969. /**
  51970. * Disposes of the gizmo
  51971. */
  51972. dispose(): void;
  51973. /**
  51974. * 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)
  51975. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  51976. * @returns the bounding box mesh with the passed in mesh as a child
  51977. */
  51978. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  51979. /**
  51980. * CustomMeshes are not supported by this gizmo
  51981. * @param mesh The mesh to replace the default mesh of the gizmo
  51982. */
  51983. setCustomMesh(mesh: Mesh): void;
  51984. }
  51985. }
  51986. declare module BABYLON {
  51987. /**
  51988. * Single plane rotation gizmo
  51989. */
  51990. export class PlaneRotationGizmo extends Gizmo {
  51991. /**
  51992. * Drag behavior responsible for the gizmos dragging interactions
  51993. */
  51994. dragBehavior: PointerDragBehavior;
  51995. private _pointerObserver;
  51996. /**
  51997. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  51998. */
  51999. snapDistance: number;
  52000. /**
  52001. * Event that fires each time the gizmo snaps to a new location.
  52002. * * snapDistance is the the change in distance
  52003. */
  52004. onSnapObservable: Observable<{
  52005. snapDistance: number;
  52006. }>;
  52007. private _isEnabled;
  52008. private _parent;
  52009. /**
  52010. * Creates a PlaneRotationGizmo
  52011. * @param gizmoLayer The utility layer the gizmo will be added to
  52012. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  52013. * @param color The color of the gizmo
  52014. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52015. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52016. */
  52017. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  52018. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52019. /**
  52020. * If the gizmo is enabled
  52021. */
  52022. set isEnabled(value: boolean);
  52023. get isEnabled(): boolean;
  52024. /**
  52025. * Disposes of the gizmo
  52026. */
  52027. dispose(): void;
  52028. }
  52029. }
  52030. declare module BABYLON {
  52031. /**
  52032. * Gizmo that enables rotating a mesh along 3 axis
  52033. */
  52034. export class RotationGizmo extends Gizmo {
  52035. /**
  52036. * Internal gizmo used for interactions on the x axis
  52037. */
  52038. xGizmo: PlaneRotationGizmo;
  52039. /**
  52040. * Internal gizmo used for interactions on the y axis
  52041. */
  52042. yGizmo: PlaneRotationGizmo;
  52043. /**
  52044. * Internal gizmo used for interactions on the z axis
  52045. */
  52046. zGizmo: PlaneRotationGizmo;
  52047. /** Fires an event when any of it's sub gizmos are dragged */
  52048. onDragStartObservable: Observable<unknown>;
  52049. /** Fires an event when any of it's sub gizmos are released from dragging */
  52050. onDragEndObservable: Observable<unknown>;
  52051. private _meshAttached;
  52052. get attachedMesh(): Nullable<AbstractMesh>;
  52053. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52054. /**
  52055. * Creates a RotationGizmo
  52056. * @param gizmoLayer The utility layer the gizmo will be added to
  52057. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52058. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52059. */
  52060. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  52061. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52062. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52063. /**
  52064. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52065. */
  52066. set snapDistance(value: number);
  52067. get snapDistance(): number;
  52068. /**
  52069. * Ratio for the scale of the gizmo (Default: 1)
  52070. */
  52071. set scaleRatio(value: number);
  52072. get scaleRatio(): number;
  52073. /**
  52074. * Disposes of the gizmo
  52075. */
  52076. dispose(): void;
  52077. /**
  52078. * CustomMeshes are not supported by this gizmo
  52079. * @param mesh The mesh to replace the default mesh of the gizmo
  52080. */
  52081. setCustomMesh(mesh: Mesh): void;
  52082. }
  52083. }
  52084. declare module BABYLON {
  52085. /**
  52086. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  52087. */
  52088. export class GizmoManager implements IDisposable {
  52089. private scene;
  52090. /**
  52091. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  52092. */
  52093. gizmos: {
  52094. positionGizmo: Nullable<PositionGizmo>;
  52095. rotationGizmo: Nullable<RotationGizmo>;
  52096. scaleGizmo: Nullable<ScaleGizmo>;
  52097. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  52098. };
  52099. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  52100. clearGizmoOnEmptyPointerEvent: boolean;
  52101. /** Fires an event when the manager is attached to a mesh */
  52102. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  52103. private _gizmosEnabled;
  52104. private _pointerObserver;
  52105. private _attachedMesh;
  52106. private _boundingBoxColor;
  52107. private _defaultUtilityLayer;
  52108. private _defaultKeepDepthUtilityLayer;
  52109. /**
  52110. * When bounding box gizmo is enabled, this can be used to track drag/end events
  52111. */
  52112. boundingBoxDragBehavior: SixDofDragBehavior;
  52113. /**
  52114. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  52115. */
  52116. attachableMeshes: Nullable<Array<AbstractMesh>>;
  52117. /**
  52118. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  52119. */
  52120. usePointerToAttachGizmos: boolean;
  52121. /**
  52122. * Utility layer that the bounding box gizmo belongs to
  52123. */
  52124. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  52125. /**
  52126. * Utility layer that all gizmos besides bounding box belong to
  52127. */
  52128. get utilityLayer(): UtilityLayerRenderer;
  52129. /**
  52130. * Instatiates a gizmo manager
  52131. * @param scene the scene to overlay the gizmos on top of
  52132. */
  52133. constructor(scene: Scene);
  52134. /**
  52135. * Attaches a set of gizmos to the specified mesh
  52136. * @param mesh The mesh the gizmo's should be attached to
  52137. */
  52138. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52139. /**
  52140. * If the position gizmo is enabled
  52141. */
  52142. set positionGizmoEnabled(value: boolean);
  52143. get positionGizmoEnabled(): boolean;
  52144. /**
  52145. * If the rotation gizmo is enabled
  52146. */
  52147. set rotationGizmoEnabled(value: boolean);
  52148. get rotationGizmoEnabled(): boolean;
  52149. /**
  52150. * If the scale gizmo is enabled
  52151. */
  52152. set scaleGizmoEnabled(value: boolean);
  52153. get scaleGizmoEnabled(): boolean;
  52154. /**
  52155. * If the boundingBox gizmo is enabled
  52156. */
  52157. set boundingBoxGizmoEnabled(value: boolean);
  52158. get boundingBoxGizmoEnabled(): boolean;
  52159. /**
  52160. * Disposes of the gizmo manager
  52161. */
  52162. dispose(): void;
  52163. }
  52164. }
  52165. declare module BABYLON {
  52166. /**
  52167. * A directional light is defined by a direction (what a surprise!).
  52168. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  52169. * 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.
  52170. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52171. */
  52172. export class DirectionalLight extends ShadowLight {
  52173. private _shadowFrustumSize;
  52174. /**
  52175. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  52176. */
  52177. get shadowFrustumSize(): number;
  52178. /**
  52179. * Specifies a fix frustum size for the shadow generation.
  52180. */
  52181. set shadowFrustumSize(value: number);
  52182. private _shadowOrthoScale;
  52183. /**
  52184. * Gets the shadow projection scale against the optimal computed one.
  52185. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  52186. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  52187. */
  52188. get shadowOrthoScale(): number;
  52189. /**
  52190. * Sets the shadow projection scale against the optimal computed one.
  52191. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  52192. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  52193. */
  52194. set shadowOrthoScale(value: number);
  52195. /**
  52196. * Automatically compute the projection matrix to best fit (including all the casters)
  52197. * on each frame.
  52198. */
  52199. autoUpdateExtends: boolean;
  52200. /**
  52201. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  52202. * on each frame. autoUpdateExtends must be set to true for this to work
  52203. */
  52204. autoCalcShadowZBounds: boolean;
  52205. private _orthoLeft;
  52206. private _orthoRight;
  52207. private _orthoTop;
  52208. private _orthoBottom;
  52209. /**
  52210. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  52211. * The directional light is emitted from everywhere in the given direction.
  52212. * It can cast shadows.
  52213. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52214. * @param name The friendly name of the light
  52215. * @param direction The direction of the light
  52216. * @param scene The scene the light belongs to
  52217. */
  52218. constructor(name: string, direction: Vector3, scene: Scene);
  52219. /**
  52220. * Returns the string "DirectionalLight".
  52221. * @return The class name
  52222. */
  52223. getClassName(): string;
  52224. /**
  52225. * Returns the integer 1.
  52226. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52227. */
  52228. getTypeID(): number;
  52229. /**
  52230. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  52231. * Returns the DirectionalLight Shadow projection matrix.
  52232. */
  52233. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52234. /**
  52235. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  52236. * Returns the DirectionalLight Shadow projection matrix.
  52237. */
  52238. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  52239. /**
  52240. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  52241. * Returns the DirectionalLight Shadow projection matrix.
  52242. */
  52243. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52244. protected _buildUniformLayout(): void;
  52245. /**
  52246. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  52247. * @param effect The effect to update
  52248. * @param lightIndex The index of the light in the effect to update
  52249. * @returns The directional light
  52250. */
  52251. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  52252. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  52253. /**
  52254. * Gets the minZ used for shadow according to both the scene and the light.
  52255. *
  52256. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  52257. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  52258. * @param activeCamera The camera we are returning the min for
  52259. * @returns the depth min z
  52260. */
  52261. getDepthMinZ(activeCamera: Camera): number;
  52262. /**
  52263. * Gets the maxZ used for shadow according to both the scene and the light.
  52264. *
  52265. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  52266. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  52267. * @param activeCamera The camera we are returning the max for
  52268. * @returns the depth max z
  52269. */
  52270. getDepthMaxZ(activeCamera: Camera): number;
  52271. /**
  52272. * Prepares the list of defines specific to the light type.
  52273. * @param defines the list of defines
  52274. * @param lightIndex defines the index of the light for the effect
  52275. */
  52276. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52277. }
  52278. }
  52279. declare module BABYLON {
  52280. /**
  52281. * Class containing static functions to help procedurally build meshes
  52282. */
  52283. export class HemisphereBuilder {
  52284. /**
  52285. * Creates a hemisphere mesh
  52286. * @param name defines the name of the mesh
  52287. * @param options defines the options used to create the mesh
  52288. * @param scene defines the hosting scene
  52289. * @returns the hemisphere mesh
  52290. */
  52291. static CreateHemisphere(name: string, options: {
  52292. segments?: number;
  52293. diameter?: number;
  52294. sideOrientation?: number;
  52295. }, scene: any): Mesh;
  52296. }
  52297. }
  52298. declare module BABYLON {
  52299. /**
  52300. * A spot light is defined by a position, a direction, an angle, and an exponent.
  52301. * These values define a cone of light starting from the position, emitting toward the direction.
  52302. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  52303. * and the exponent defines the speed of the decay of the light with distance (reach).
  52304. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52305. */
  52306. export class SpotLight extends ShadowLight {
  52307. private _angle;
  52308. private _innerAngle;
  52309. private _cosHalfAngle;
  52310. private _lightAngleScale;
  52311. private _lightAngleOffset;
  52312. /**
  52313. * Gets the cone angle of the spot light in Radians.
  52314. */
  52315. get angle(): number;
  52316. /**
  52317. * Sets the cone angle of the spot light in Radians.
  52318. */
  52319. set angle(value: number);
  52320. /**
  52321. * Only used in gltf falloff mode, this defines the angle where
  52322. * the directional falloff will start before cutting at angle which could be seen
  52323. * as outer angle.
  52324. */
  52325. get innerAngle(): number;
  52326. /**
  52327. * Only used in gltf falloff mode, this defines the angle where
  52328. * the directional falloff will start before cutting at angle which could be seen
  52329. * as outer angle.
  52330. */
  52331. set innerAngle(value: number);
  52332. private _shadowAngleScale;
  52333. /**
  52334. * Allows scaling the angle of the light for shadow generation only.
  52335. */
  52336. get shadowAngleScale(): number;
  52337. /**
  52338. * Allows scaling the angle of the light for shadow generation only.
  52339. */
  52340. set shadowAngleScale(value: number);
  52341. /**
  52342. * The light decay speed with the distance from the emission spot.
  52343. */
  52344. exponent: number;
  52345. private _projectionTextureMatrix;
  52346. /**
  52347. * Allows reading the projecton texture
  52348. */
  52349. get projectionTextureMatrix(): Matrix;
  52350. protected _projectionTextureLightNear: number;
  52351. /**
  52352. * Gets the near clip of the Spotlight for texture projection.
  52353. */
  52354. get projectionTextureLightNear(): number;
  52355. /**
  52356. * Sets the near clip of the Spotlight for texture projection.
  52357. */
  52358. set projectionTextureLightNear(value: number);
  52359. protected _projectionTextureLightFar: number;
  52360. /**
  52361. * Gets the far clip of the Spotlight for texture projection.
  52362. */
  52363. get projectionTextureLightFar(): number;
  52364. /**
  52365. * Sets the far clip of the Spotlight for texture projection.
  52366. */
  52367. set projectionTextureLightFar(value: number);
  52368. protected _projectionTextureUpDirection: Vector3;
  52369. /**
  52370. * Gets the Up vector of the Spotlight for texture projection.
  52371. */
  52372. get projectionTextureUpDirection(): Vector3;
  52373. /**
  52374. * Sets the Up vector of the Spotlight for texture projection.
  52375. */
  52376. set projectionTextureUpDirection(value: Vector3);
  52377. private _projectionTexture;
  52378. /**
  52379. * Gets the projection texture of the light.
  52380. */
  52381. get projectionTexture(): Nullable<BaseTexture>;
  52382. /**
  52383. * Sets the projection texture of the light.
  52384. */
  52385. set projectionTexture(value: Nullable<BaseTexture>);
  52386. private _projectionTextureViewLightDirty;
  52387. private _projectionTextureProjectionLightDirty;
  52388. private _projectionTextureDirty;
  52389. private _projectionTextureViewTargetVector;
  52390. private _projectionTextureViewLightMatrix;
  52391. private _projectionTextureProjectionLightMatrix;
  52392. private _projectionTextureScalingMatrix;
  52393. /**
  52394. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  52395. * It can cast shadows.
  52396. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52397. * @param name The light friendly name
  52398. * @param position The position of the spot light in the scene
  52399. * @param direction The direction of the light in the scene
  52400. * @param angle The cone angle of the light in Radians
  52401. * @param exponent The light decay speed with the distance from the emission spot
  52402. * @param scene The scene the lights belongs to
  52403. */
  52404. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  52405. /**
  52406. * Returns the string "SpotLight".
  52407. * @returns the class name
  52408. */
  52409. getClassName(): string;
  52410. /**
  52411. * Returns the integer 2.
  52412. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52413. */
  52414. getTypeID(): number;
  52415. /**
  52416. * Overrides the direction setter to recompute the projection texture view light Matrix.
  52417. */
  52418. protected _setDirection(value: Vector3): void;
  52419. /**
  52420. * Overrides the position setter to recompute the projection texture view light Matrix.
  52421. */
  52422. protected _setPosition(value: Vector3): void;
  52423. /**
  52424. * 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.
  52425. * Returns the SpotLight.
  52426. */
  52427. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52428. protected _computeProjectionTextureViewLightMatrix(): void;
  52429. protected _computeProjectionTextureProjectionLightMatrix(): void;
  52430. /**
  52431. * Main function for light texture projection matrix computing.
  52432. */
  52433. protected _computeProjectionTextureMatrix(): void;
  52434. protected _buildUniformLayout(): void;
  52435. private _computeAngleValues;
  52436. /**
  52437. * Sets the passed Effect "effect" with the Light textures.
  52438. * @param effect The effect to update
  52439. * @param lightIndex The index of the light in the effect to update
  52440. * @returns The light
  52441. */
  52442. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  52443. /**
  52444. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  52445. * @param effect The effect to update
  52446. * @param lightIndex The index of the light in the effect to update
  52447. * @returns The spot light
  52448. */
  52449. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  52450. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52451. /**
  52452. * Disposes the light and the associated resources.
  52453. */
  52454. dispose(): void;
  52455. /**
  52456. * Prepares the list of defines specific to the light type.
  52457. * @param defines the list of defines
  52458. * @param lightIndex defines the index of the light for the effect
  52459. */
  52460. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52461. }
  52462. }
  52463. declare module BABYLON {
  52464. /**
  52465. * Gizmo that enables viewing a light
  52466. */
  52467. export class LightGizmo extends Gizmo {
  52468. private _lightMesh;
  52469. private _material;
  52470. private _cachedPosition;
  52471. private _cachedForward;
  52472. private _attachedMeshParent;
  52473. /**
  52474. * Creates a LightGizmo
  52475. * @param gizmoLayer The utility layer the gizmo will be added to
  52476. */
  52477. constructor(gizmoLayer?: UtilityLayerRenderer);
  52478. private _light;
  52479. /**
  52480. * The light that the gizmo is attached to
  52481. */
  52482. set light(light: Nullable<Light>);
  52483. get light(): Nullable<Light>;
  52484. /**
  52485. * Gets the material used to render the light gizmo
  52486. */
  52487. get material(): StandardMaterial;
  52488. /**
  52489. * @hidden
  52490. * Updates the gizmo to match the attached mesh's position/rotation
  52491. */
  52492. protected _update(): void;
  52493. private static _Scale;
  52494. /**
  52495. * Creates the lines for a light mesh
  52496. */
  52497. private static _CreateLightLines;
  52498. /**
  52499. * Disposes of the light gizmo
  52500. */
  52501. dispose(): void;
  52502. private static _CreateHemisphericLightMesh;
  52503. private static _CreatePointLightMesh;
  52504. private static _CreateSpotLightMesh;
  52505. private static _CreateDirectionalLightMesh;
  52506. }
  52507. }
  52508. declare module BABYLON {
  52509. /** @hidden */
  52510. export var backgroundFragmentDeclaration: {
  52511. name: string;
  52512. shader: string;
  52513. };
  52514. }
  52515. declare module BABYLON {
  52516. /** @hidden */
  52517. export var backgroundUboDeclaration: {
  52518. name: string;
  52519. shader: string;
  52520. };
  52521. }
  52522. declare module BABYLON {
  52523. /** @hidden */
  52524. export var backgroundPixelShader: {
  52525. name: string;
  52526. shader: string;
  52527. };
  52528. }
  52529. declare module BABYLON {
  52530. /** @hidden */
  52531. export var backgroundVertexDeclaration: {
  52532. name: string;
  52533. shader: string;
  52534. };
  52535. }
  52536. declare module BABYLON {
  52537. /** @hidden */
  52538. export var backgroundVertexShader: {
  52539. name: string;
  52540. shader: string;
  52541. };
  52542. }
  52543. declare module BABYLON {
  52544. /**
  52545. * Background material used to create an efficient environement around your scene.
  52546. */
  52547. export class BackgroundMaterial extends PushMaterial {
  52548. /**
  52549. * Standard reflectance value at parallel view angle.
  52550. */
  52551. static StandardReflectance0: number;
  52552. /**
  52553. * Standard reflectance value at grazing angle.
  52554. */
  52555. static StandardReflectance90: number;
  52556. protected _primaryColor: Color3;
  52557. /**
  52558. * Key light Color (multiply against the environement texture)
  52559. */
  52560. primaryColor: Color3;
  52561. protected __perceptualColor: Nullable<Color3>;
  52562. /**
  52563. * Experimental Internal Use Only.
  52564. *
  52565. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  52566. * This acts as a helper to set the primary color to a more "human friendly" value.
  52567. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  52568. * output color as close as possible from the chosen value.
  52569. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  52570. * part of lighting setup.)
  52571. */
  52572. get _perceptualColor(): Nullable<Color3>;
  52573. set _perceptualColor(value: Nullable<Color3>);
  52574. protected _primaryColorShadowLevel: float;
  52575. /**
  52576. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  52577. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  52578. */
  52579. get primaryColorShadowLevel(): float;
  52580. set primaryColorShadowLevel(value: float);
  52581. protected _primaryColorHighlightLevel: float;
  52582. /**
  52583. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  52584. * The primary color is used at the level chosen to define what the white area would look.
  52585. */
  52586. get primaryColorHighlightLevel(): float;
  52587. set primaryColorHighlightLevel(value: float);
  52588. protected _reflectionTexture: Nullable<BaseTexture>;
  52589. /**
  52590. * Reflection Texture used in the material.
  52591. * Should be author in a specific way for the best result (refer to the documentation).
  52592. */
  52593. reflectionTexture: Nullable<BaseTexture>;
  52594. protected _reflectionBlur: float;
  52595. /**
  52596. * Reflection Texture level of blur.
  52597. *
  52598. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  52599. * texture twice.
  52600. */
  52601. reflectionBlur: float;
  52602. protected _diffuseTexture: Nullable<BaseTexture>;
  52603. /**
  52604. * Diffuse Texture used in the material.
  52605. * Should be author in a specific way for the best result (refer to the documentation).
  52606. */
  52607. diffuseTexture: Nullable<BaseTexture>;
  52608. protected _shadowLights: Nullable<IShadowLight[]>;
  52609. /**
  52610. * Specify the list of lights casting shadow on the material.
  52611. * All scene shadow lights will be included if null.
  52612. */
  52613. shadowLights: Nullable<IShadowLight[]>;
  52614. protected _shadowLevel: float;
  52615. /**
  52616. * Helps adjusting the shadow to a softer level if required.
  52617. * 0 means black shadows and 1 means no shadows.
  52618. */
  52619. shadowLevel: float;
  52620. protected _sceneCenter: Vector3;
  52621. /**
  52622. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  52623. * It is usually zero but might be interesting to modify according to your setup.
  52624. */
  52625. sceneCenter: Vector3;
  52626. protected _opacityFresnel: boolean;
  52627. /**
  52628. * This helps specifying that the material is falling off to the sky box at grazing angle.
  52629. * This helps ensuring a nice transition when the camera goes under the ground.
  52630. */
  52631. opacityFresnel: boolean;
  52632. protected _reflectionFresnel: boolean;
  52633. /**
  52634. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  52635. * This helps adding a mirror texture on the ground.
  52636. */
  52637. reflectionFresnel: boolean;
  52638. protected _reflectionFalloffDistance: number;
  52639. /**
  52640. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  52641. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  52642. */
  52643. reflectionFalloffDistance: number;
  52644. protected _reflectionAmount: number;
  52645. /**
  52646. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  52647. */
  52648. reflectionAmount: number;
  52649. protected _reflectionReflectance0: number;
  52650. /**
  52651. * This specifies the weight of the reflection at grazing angle.
  52652. */
  52653. reflectionReflectance0: number;
  52654. protected _reflectionReflectance90: number;
  52655. /**
  52656. * This specifies the weight of the reflection at a perpendicular point of view.
  52657. */
  52658. reflectionReflectance90: number;
  52659. /**
  52660. * Sets the reflection reflectance fresnel values according to the default standard
  52661. * empirically know to work well :-)
  52662. */
  52663. set reflectionStandardFresnelWeight(value: number);
  52664. protected _useRGBColor: boolean;
  52665. /**
  52666. * Helps to directly use the maps channels instead of their level.
  52667. */
  52668. useRGBColor: boolean;
  52669. protected _enableNoise: boolean;
  52670. /**
  52671. * This helps reducing the banding effect that could occur on the background.
  52672. */
  52673. enableNoise: boolean;
  52674. /**
  52675. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52676. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  52677. * Recommended to be keep at 1.0 except for special cases.
  52678. */
  52679. get fovMultiplier(): number;
  52680. set fovMultiplier(value: number);
  52681. private _fovMultiplier;
  52682. /**
  52683. * Enable the FOV adjustment feature controlled by fovMultiplier.
  52684. */
  52685. useEquirectangularFOV: boolean;
  52686. private _maxSimultaneousLights;
  52687. /**
  52688. * Number of Simultaneous lights allowed on the material.
  52689. */
  52690. maxSimultaneousLights: int;
  52691. /**
  52692. * Default configuration related to image processing available in the Background Material.
  52693. */
  52694. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52695. /**
  52696. * Keep track of the image processing observer to allow dispose and replace.
  52697. */
  52698. private _imageProcessingObserver;
  52699. /**
  52700. * Attaches a new image processing configuration to the PBR Material.
  52701. * @param configuration (if null the scene configuration will be use)
  52702. */
  52703. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52704. /**
  52705. * Gets the image processing configuration used either in this material.
  52706. */
  52707. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  52708. /**
  52709. * Sets the Default image processing configuration used either in the this material.
  52710. *
  52711. * If sets to null, the scene one is in use.
  52712. */
  52713. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  52714. /**
  52715. * Gets wether the color curves effect is enabled.
  52716. */
  52717. get cameraColorCurvesEnabled(): boolean;
  52718. /**
  52719. * Sets wether the color curves effect is enabled.
  52720. */
  52721. set cameraColorCurvesEnabled(value: boolean);
  52722. /**
  52723. * Gets wether the color grading effect is enabled.
  52724. */
  52725. get cameraColorGradingEnabled(): boolean;
  52726. /**
  52727. * Gets wether the color grading effect is enabled.
  52728. */
  52729. set cameraColorGradingEnabled(value: boolean);
  52730. /**
  52731. * Gets wether tonemapping is enabled or not.
  52732. */
  52733. get cameraToneMappingEnabled(): boolean;
  52734. /**
  52735. * Sets wether tonemapping is enabled or not
  52736. */
  52737. set cameraToneMappingEnabled(value: boolean);
  52738. /**
  52739. * The camera exposure used on this material.
  52740. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52741. * This corresponds to a photographic exposure.
  52742. */
  52743. get cameraExposure(): float;
  52744. /**
  52745. * The camera exposure used on this material.
  52746. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52747. * This corresponds to a photographic exposure.
  52748. */
  52749. set cameraExposure(value: float);
  52750. /**
  52751. * Gets The camera contrast used on this material.
  52752. */
  52753. get cameraContrast(): float;
  52754. /**
  52755. * Sets The camera contrast used on this material.
  52756. */
  52757. set cameraContrast(value: float);
  52758. /**
  52759. * Gets the Color Grading 2D Lookup Texture.
  52760. */
  52761. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52762. /**
  52763. * Sets the Color Grading 2D Lookup Texture.
  52764. */
  52765. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52766. /**
  52767. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52768. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52769. * 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;
  52770. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52771. */
  52772. get cameraColorCurves(): Nullable<ColorCurves>;
  52773. /**
  52774. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52775. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52776. * 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;
  52777. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52778. */
  52779. set cameraColorCurves(value: Nullable<ColorCurves>);
  52780. /**
  52781. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  52782. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  52783. */
  52784. switchToBGR: boolean;
  52785. private _renderTargets;
  52786. private _reflectionControls;
  52787. private _white;
  52788. private _primaryShadowColor;
  52789. private _primaryHighlightColor;
  52790. /**
  52791. * Instantiates a Background Material in the given scene
  52792. * @param name The friendly name of the material
  52793. * @param scene The scene to add the material to
  52794. */
  52795. constructor(name: string, scene: Scene);
  52796. /**
  52797. * Gets a boolean indicating that current material needs to register RTT
  52798. */
  52799. get hasRenderTargetTextures(): boolean;
  52800. /**
  52801. * The entire material has been created in order to prevent overdraw.
  52802. * @returns false
  52803. */
  52804. needAlphaTesting(): boolean;
  52805. /**
  52806. * The entire material has been created in order to prevent overdraw.
  52807. * @returns true if blending is enable
  52808. */
  52809. needAlphaBlending(): boolean;
  52810. /**
  52811. * Checks wether the material is ready to be rendered for a given mesh.
  52812. * @param mesh The mesh to render
  52813. * @param subMesh The submesh to check against
  52814. * @param useInstances Specify wether or not the material is used with instances
  52815. * @returns true if all the dependencies are ready (Textures, Effects...)
  52816. */
  52817. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52818. /**
  52819. * Compute the primary color according to the chosen perceptual color.
  52820. */
  52821. private _computePrimaryColorFromPerceptualColor;
  52822. /**
  52823. * Compute the highlights and shadow colors according to their chosen levels.
  52824. */
  52825. private _computePrimaryColors;
  52826. /**
  52827. * Build the uniform buffer used in the material.
  52828. */
  52829. buildUniformLayout(): void;
  52830. /**
  52831. * Unbind the material.
  52832. */
  52833. unbind(): void;
  52834. /**
  52835. * Bind only the world matrix to the material.
  52836. * @param world The world matrix to bind.
  52837. */
  52838. bindOnlyWorldMatrix(world: Matrix): void;
  52839. /**
  52840. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  52841. * @param world The world matrix to bind.
  52842. * @param subMesh The submesh to bind for.
  52843. */
  52844. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52845. /**
  52846. * Checks to see if a texture is used in the material.
  52847. * @param texture - Base texture to use.
  52848. * @returns - Boolean specifying if a texture is used in the material.
  52849. */
  52850. hasTexture(texture: BaseTexture): boolean;
  52851. /**
  52852. * Dispose the material.
  52853. * @param forceDisposeEffect Force disposal of the associated effect.
  52854. * @param forceDisposeTextures Force disposal of the associated textures.
  52855. */
  52856. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  52857. /**
  52858. * Clones the material.
  52859. * @param name The cloned name.
  52860. * @returns The cloned material.
  52861. */
  52862. clone(name: string): BackgroundMaterial;
  52863. /**
  52864. * Serializes the current material to its JSON representation.
  52865. * @returns The JSON representation.
  52866. */
  52867. serialize(): any;
  52868. /**
  52869. * Gets the class name of the material
  52870. * @returns "BackgroundMaterial"
  52871. */
  52872. getClassName(): string;
  52873. /**
  52874. * Parse a JSON input to create back a background material.
  52875. * @param source The JSON data to parse
  52876. * @param scene The scene to create the parsed material in
  52877. * @param rootUrl The root url of the assets the material depends upon
  52878. * @returns the instantiated BackgroundMaterial.
  52879. */
  52880. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  52881. }
  52882. }
  52883. declare module BABYLON {
  52884. /**
  52885. * Represents the different options available during the creation of
  52886. * a Environment helper.
  52887. *
  52888. * This can control the default ground, skybox and image processing setup of your scene.
  52889. */
  52890. export interface IEnvironmentHelperOptions {
  52891. /**
  52892. * Specifies whether or not to create a ground.
  52893. * True by default.
  52894. */
  52895. createGround: boolean;
  52896. /**
  52897. * Specifies the ground size.
  52898. * 15 by default.
  52899. */
  52900. groundSize: number;
  52901. /**
  52902. * The texture used on the ground for the main color.
  52903. * Comes from the BabylonJS CDN by default.
  52904. *
  52905. * Remarks: Can be either a texture or a url.
  52906. */
  52907. groundTexture: string | BaseTexture;
  52908. /**
  52909. * The color mixed in the ground texture by default.
  52910. * BabylonJS clearColor by default.
  52911. */
  52912. groundColor: Color3;
  52913. /**
  52914. * Specifies the ground opacity.
  52915. * 1 by default.
  52916. */
  52917. groundOpacity: number;
  52918. /**
  52919. * Enables the ground to receive shadows.
  52920. * True by default.
  52921. */
  52922. enableGroundShadow: boolean;
  52923. /**
  52924. * Helps preventing the shadow to be fully black on the ground.
  52925. * 0.5 by default.
  52926. */
  52927. groundShadowLevel: number;
  52928. /**
  52929. * Creates a mirror texture attach to the ground.
  52930. * false by default.
  52931. */
  52932. enableGroundMirror: boolean;
  52933. /**
  52934. * Specifies the ground mirror size ratio.
  52935. * 0.3 by default as the default kernel is 64.
  52936. */
  52937. groundMirrorSizeRatio: number;
  52938. /**
  52939. * Specifies the ground mirror blur kernel size.
  52940. * 64 by default.
  52941. */
  52942. groundMirrorBlurKernel: number;
  52943. /**
  52944. * Specifies the ground mirror visibility amount.
  52945. * 1 by default
  52946. */
  52947. groundMirrorAmount: number;
  52948. /**
  52949. * Specifies the ground mirror reflectance weight.
  52950. * This uses the standard weight of the background material to setup the fresnel effect
  52951. * of the mirror.
  52952. * 1 by default.
  52953. */
  52954. groundMirrorFresnelWeight: number;
  52955. /**
  52956. * Specifies the ground mirror Falloff distance.
  52957. * This can helps reducing the size of the reflection.
  52958. * 0 by Default.
  52959. */
  52960. groundMirrorFallOffDistance: number;
  52961. /**
  52962. * Specifies the ground mirror texture type.
  52963. * Unsigned Int by Default.
  52964. */
  52965. groundMirrorTextureType: number;
  52966. /**
  52967. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  52968. * the shown objects.
  52969. */
  52970. groundYBias: number;
  52971. /**
  52972. * Specifies whether or not to create a skybox.
  52973. * True by default.
  52974. */
  52975. createSkybox: boolean;
  52976. /**
  52977. * Specifies the skybox size.
  52978. * 20 by default.
  52979. */
  52980. skyboxSize: number;
  52981. /**
  52982. * The texture used on the skybox for the main color.
  52983. * Comes from the BabylonJS CDN by default.
  52984. *
  52985. * Remarks: Can be either a texture or a url.
  52986. */
  52987. skyboxTexture: string | BaseTexture;
  52988. /**
  52989. * The color mixed in the skybox texture by default.
  52990. * BabylonJS clearColor by default.
  52991. */
  52992. skyboxColor: Color3;
  52993. /**
  52994. * The background rotation around the Y axis of the scene.
  52995. * This helps aligning the key lights of your scene with the background.
  52996. * 0 by default.
  52997. */
  52998. backgroundYRotation: number;
  52999. /**
  53000. * Compute automatically the size of the elements to best fit with the scene.
  53001. */
  53002. sizeAuto: boolean;
  53003. /**
  53004. * Default position of the rootMesh if autoSize is not true.
  53005. */
  53006. rootPosition: Vector3;
  53007. /**
  53008. * Sets up the image processing in the scene.
  53009. * true by default.
  53010. */
  53011. setupImageProcessing: boolean;
  53012. /**
  53013. * The texture used as your environment texture in the scene.
  53014. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  53015. *
  53016. * Remarks: Can be either a texture or a url.
  53017. */
  53018. environmentTexture: string | BaseTexture;
  53019. /**
  53020. * The value of the exposure to apply to the scene.
  53021. * 0.6 by default if setupImageProcessing is true.
  53022. */
  53023. cameraExposure: number;
  53024. /**
  53025. * The value of the contrast to apply to the scene.
  53026. * 1.6 by default if setupImageProcessing is true.
  53027. */
  53028. cameraContrast: number;
  53029. /**
  53030. * Specifies whether or not tonemapping should be enabled in the scene.
  53031. * true by default if setupImageProcessing is true.
  53032. */
  53033. toneMappingEnabled: boolean;
  53034. }
  53035. /**
  53036. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  53037. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  53038. * It also helps with the default setup of your imageProcessing configuration.
  53039. */
  53040. export class EnvironmentHelper {
  53041. /**
  53042. * Default ground texture URL.
  53043. */
  53044. private static _groundTextureCDNUrl;
  53045. /**
  53046. * Default skybox texture URL.
  53047. */
  53048. private static _skyboxTextureCDNUrl;
  53049. /**
  53050. * Default environment texture URL.
  53051. */
  53052. private static _environmentTextureCDNUrl;
  53053. /**
  53054. * Creates the default options for the helper.
  53055. */
  53056. private static _getDefaultOptions;
  53057. private _rootMesh;
  53058. /**
  53059. * Gets the root mesh created by the helper.
  53060. */
  53061. get rootMesh(): Mesh;
  53062. private _skybox;
  53063. /**
  53064. * Gets the skybox created by the helper.
  53065. */
  53066. get skybox(): Nullable<Mesh>;
  53067. private _skyboxTexture;
  53068. /**
  53069. * Gets the skybox texture created by the helper.
  53070. */
  53071. get skyboxTexture(): Nullable<BaseTexture>;
  53072. private _skyboxMaterial;
  53073. /**
  53074. * Gets the skybox material created by the helper.
  53075. */
  53076. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  53077. private _ground;
  53078. /**
  53079. * Gets the ground mesh created by the helper.
  53080. */
  53081. get ground(): Nullable<Mesh>;
  53082. private _groundTexture;
  53083. /**
  53084. * Gets the ground texture created by the helper.
  53085. */
  53086. get groundTexture(): Nullable<BaseTexture>;
  53087. private _groundMirror;
  53088. /**
  53089. * Gets the ground mirror created by the helper.
  53090. */
  53091. get groundMirror(): Nullable<MirrorTexture>;
  53092. /**
  53093. * Gets the ground mirror render list to helps pushing the meshes
  53094. * you wish in the ground reflection.
  53095. */
  53096. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  53097. private _groundMaterial;
  53098. /**
  53099. * Gets the ground material created by the helper.
  53100. */
  53101. get groundMaterial(): Nullable<BackgroundMaterial>;
  53102. /**
  53103. * Stores the creation options.
  53104. */
  53105. private readonly _scene;
  53106. private _options;
  53107. /**
  53108. * This observable will be notified with any error during the creation of the environment,
  53109. * mainly texture creation errors.
  53110. */
  53111. onErrorObservable: Observable<{
  53112. message?: string;
  53113. exception?: any;
  53114. }>;
  53115. /**
  53116. * constructor
  53117. * @param options Defines the options we want to customize the helper
  53118. * @param scene The scene to add the material to
  53119. */
  53120. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  53121. /**
  53122. * Updates the background according to the new options
  53123. * @param options
  53124. */
  53125. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  53126. /**
  53127. * Sets the primary color of all the available elements.
  53128. * @param color the main color to affect to the ground and the background
  53129. */
  53130. setMainColor(color: Color3): void;
  53131. /**
  53132. * Setup the image processing according to the specified options.
  53133. */
  53134. private _setupImageProcessing;
  53135. /**
  53136. * Setup the environment texture according to the specified options.
  53137. */
  53138. private _setupEnvironmentTexture;
  53139. /**
  53140. * Setup the background according to the specified options.
  53141. */
  53142. private _setupBackground;
  53143. /**
  53144. * Get the scene sizes according to the setup.
  53145. */
  53146. private _getSceneSize;
  53147. /**
  53148. * Setup the ground according to the specified options.
  53149. */
  53150. private _setupGround;
  53151. /**
  53152. * Setup the ground material according to the specified options.
  53153. */
  53154. private _setupGroundMaterial;
  53155. /**
  53156. * Setup the ground diffuse texture according to the specified options.
  53157. */
  53158. private _setupGroundDiffuseTexture;
  53159. /**
  53160. * Setup the ground mirror texture according to the specified options.
  53161. */
  53162. private _setupGroundMirrorTexture;
  53163. /**
  53164. * Setup the ground to receive the mirror texture.
  53165. */
  53166. private _setupMirrorInGroundMaterial;
  53167. /**
  53168. * Setup the skybox according to the specified options.
  53169. */
  53170. private _setupSkybox;
  53171. /**
  53172. * Setup the skybox material according to the specified options.
  53173. */
  53174. private _setupSkyboxMaterial;
  53175. /**
  53176. * Setup the skybox reflection texture according to the specified options.
  53177. */
  53178. private _setupSkyboxReflectionTexture;
  53179. private _errorHandler;
  53180. /**
  53181. * Dispose all the elements created by the Helper.
  53182. */
  53183. dispose(): void;
  53184. }
  53185. }
  53186. declare module BABYLON {
  53187. /**
  53188. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  53189. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  53190. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  53191. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  53192. */
  53193. export class PhotoDome extends TransformNode {
  53194. /**
  53195. * Define the image as a Monoscopic panoramic 360 image.
  53196. */
  53197. static readonly MODE_MONOSCOPIC: number;
  53198. /**
  53199. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53200. */
  53201. static readonly MODE_TOPBOTTOM: number;
  53202. /**
  53203. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53204. */
  53205. static readonly MODE_SIDEBYSIDE: number;
  53206. private _useDirectMapping;
  53207. /**
  53208. * The texture being displayed on the sphere
  53209. */
  53210. protected _photoTexture: Texture;
  53211. /**
  53212. * Gets or sets the texture being displayed on the sphere
  53213. */
  53214. get photoTexture(): Texture;
  53215. set photoTexture(value: Texture);
  53216. /**
  53217. * Observable raised when an error occured while loading the 360 image
  53218. */
  53219. onLoadErrorObservable: Observable<string>;
  53220. /**
  53221. * The skybox material
  53222. */
  53223. protected _material: BackgroundMaterial;
  53224. /**
  53225. * The surface used for the skybox
  53226. */
  53227. protected _mesh: Mesh;
  53228. /**
  53229. * Gets the mesh used for the skybox.
  53230. */
  53231. get mesh(): Mesh;
  53232. /**
  53233. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53234. * Also see the options.resolution property.
  53235. */
  53236. get fovMultiplier(): number;
  53237. set fovMultiplier(value: number);
  53238. private _imageMode;
  53239. /**
  53240. * Gets or set the current video mode for the video. It can be:
  53241. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  53242. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53243. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53244. */
  53245. get imageMode(): number;
  53246. set imageMode(value: number);
  53247. /**
  53248. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  53249. * @param name Element's name, child elements will append suffixes for their own names.
  53250. * @param urlsOfPhoto defines the url of the photo to display
  53251. * @param options defines an object containing optional or exposed sub element properties
  53252. * @param onError defines a callback called when an error occured while loading the texture
  53253. */
  53254. constructor(name: string, urlOfPhoto: string, options: {
  53255. resolution?: number;
  53256. size?: number;
  53257. useDirectMapping?: boolean;
  53258. faceForward?: boolean;
  53259. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  53260. private _onBeforeCameraRenderObserver;
  53261. private _changeImageMode;
  53262. /**
  53263. * Releases resources associated with this node.
  53264. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  53265. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  53266. */
  53267. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  53268. }
  53269. }
  53270. declare module BABYLON {
  53271. /**
  53272. * Class used to host RGBD texture specific utilities
  53273. */
  53274. export class RGBDTextureTools {
  53275. /**
  53276. * Expand the RGBD Texture from RGBD to Half Float if possible.
  53277. * @param texture the texture to expand.
  53278. */
  53279. static ExpandRGBDTexture(texture: Texture): void;
  53280. }
  53281. }
  53282. declare module BABYLON {
  53283. /**
  53284. * Class used to host texture specific utilities
  53285. */
  53286. export class BRDFTextureTools {
  53287. /**
  53288. * Prevents texture cache collision
  53289. */
  53290. private static _instanceNumber;
  53291. /**
  53292. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  53293. * @param scene defines the hosting scene
  53294. * @returns the environment BRDF texture
  53295. */
  53296. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  53297. private static _environmentBRDFBase64Texture;
  53298. }
  53299. }
  53300. declare module BABYLON {
  53301. /**
  53302. * @hidden
  53303. */
  53304. export interface IMaterialClearCoatDefines {
  53305. CLEARCOAT: boolean;
  53306. CLEARCOAT_DEFAULTIOR: boolean;
  53307. CLEARCOAT_TEXTURE: boolean;
  53308. CLEARCOAT_TEXTUREDIRECTUV: number;
  53309. CLEARCOAT_BUMP: boolean;
  53310. CLEARCOAT_BUMPDIRECTUV: number;
  53311. CLEARCOAT_TINT: boolean;
  53312. CLEARCOAT_TINT_TEXTURE: boolean;
  53313. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53314. /** @hidden */
  53315. _areTexturesDirty: boolean;
  53316. }
  53317. /**
  53318. * Define the code related to the clear coat parameters of the pbr material.
  53319. */
  53320. export class PBRClearCoatConfiguration {
  53321. /**
  53322. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53323. * The default fits with a polyurethane material.
  53324. */
  53325. private static readonly _DefaultIndexOfRefraction;
  53326. private _isEnabled;
  53327. /**
  53328. * Defines if the clear coat is enabled in the material.
  53329. */
  53330. isEnabled: boolean;
  53331. /**
  53332. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  53333. */
  53334. intensity: number;
  53335. /**
  53336. * Defines the clear coat layer roughness.
  53337. */
  53338. roughness: number;
  53339. private _indexOfRefraction;
  53340. /**
  53341. * Defines the index of refraction of the clear coat.
  53342. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53343. * The default fits with a polyurethane material.
  53344. * Changing the default value is more performance intensive.
  53345. */
  53346. indexOfRefraction: number;
  53347. private _texture;
  53348. /**
  53349. * Stores the clear coat values in a texture.
  53350. */
  53351. texture: Nullable<BaseTexture>;
  53352. private _bumpTexture;
  53353. /**
  53354. * Define the clear coat specific bump texture.
  53355. */
  53356. bumpTexture: Nullable<BaseTexture>;
  53357. private _isTintEnabled;
  53358. /**
  53359. * Defines if the clear coat tint is enabled in the material.
  53360. */
  53361. isTintEnabled: boolean;
  53362. /**
  53363. * Defines the clear coat tint of the material.
  53364. * This is only use if tint is enabled
  53365. */
  53366. tintColor: Color3;
  53367. /**
  53368. * Defines the distance at which the tint color should be found in the
  53369. * clear coat media.
  53370. * This is only use if tint is enabled
  53371. */
  53372. tintColorAtDistance: number;
  53373. /**
  53374. * Defines the clear coat layer thickness.
  53375. * This is only use if tint is enabled
  53376. */
  53377. tintThickness: number;
  53378. private _tintTexture;
  53379. /**
  53380. * Stores the clear tint values in a texture.
  53381. * rgb is tint
  53382. * a is a thickness factor
  53383. */
  53384. tintTexture: Nullable<BaseTexture>;
  53385. /** @hidden */
  53386. private _internalMarkAllSubMeshesAsTexturesDirty;
  53387. /** @hidden */
  53388. _markAllSubMeshesAsTexturesDirty(): void;
  53389. /**
  53390. * Instantiate a new istance of clear coat configuration.
  53391. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53392. */
  53393. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53394. /**
  53395. * Gets wehter the submesh is ready to be used or not.
  53396. * @param defines the list of "defines" to update.
  53397. * @param scene defines the scene the material belongs to.
  53398. * @param engine defines the engine the material belongs to.
  53399. * @param disableBumpMap defines wether the material disables bump or not.
  53400. * @returns - boolean indicating that the submesh is ready or not.
  53401. */
  53402. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  53403. /**
  53404. * Checks to see if a texture is used in the material.
  53405. * @param defines the list of "defines" to update.
  53406. * @param scene defines the scene to the material belongs to.
  53407. */
  53408. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  53409. /**
  53410. * Binds the material data.
  53411. * @param uniformBuffer defines the Uniform buffer to fill in.
  53412. * @param scene defines the scene the material belongs to.
  53413. * @param engine defines the engine the material belongs to.
  53414. * @param disableBumpMap defines wether the material disables bump or not.
  53415. * @param isFrozen defines wether the material is frozen or not.
  53416. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53417. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53418. */
  53419. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  53420. /**
  53421. * Checks to see if a texture is used in the material.
  53422. * @param texture - Base texture to use.
  53423. * @returns - Boolean specifying if a texture is used in the material.
  53424. */
  53425. hasTexture(texture: BaseTexture): boolean;
  53426. /**
  53427. * Returns an array of the actively used textures.
  53428. * @param activeTextures Array of BaseTextures
  53429. */
  53430. getActiveTextures(activeTextures: BaseTexture[]): void;
  53431. /**
  53432. * Returns the animatable textures.
  53433. * @param animatables Array of animatable textures.
  53434. */
  53435. getAnimatables(animatables: IAnimatable[]): void;
  53436. /**
  53437. * Disposes the resources of the material.
  53438. * @param forceDisposeTextures - Forces the disposal of all textures.
  53439. */
  53440. dispose(forceDisposeTextures?: boolean): void;
  53441. /**
  53442. * Get the current class name of the texture useful for serialization or dynamic coding.
  53443. * @returns "PBRClearCoatConfiguration"
  53444. */
  53445. getClassName(): string;
  53446. /**
  53447. * Add fallbacks to the effect fallbacks list.
  53448. * @param defines defines the Base texture to use.
  53449. * @param fallbacks defines the current fallback list.
  53450. * @param currentRank defines the current fallback rank.
  53451. * @returns the new fallback rank.
  53452. */
  53453. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53454. /**
  53455. * Add the required uniforms to the current list.
  53456. * @param uniforms defines the current uniform list.
  53457. */
  53458. static AddUniforms(uniforms: string[]): void;
  53459. /**
  53460. * Add the required samplers to the current list.
  53461. * @param samplers defines the current sampler list.
  53462. */
  53463. static AddSamplers(samplers: string[]): void;
  53464. /**
  53465. * Add the required uniforms to the current buffer.
  53466. * @param uniformBuffer defines the current uniform buffer.
  53467. */
  53468. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53469. /**
  53470. * Makes a duplicate of the current configuration into another one.
  53471. * @param clearCoatConfiguration define the config where to copy the info
  53472. */
  53473. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  53474. /**
  53475. * Serializes this clear coat configuration.
  53476. * @returns - An object with the serialized config.
  53477. */
  53478. serialize(): any;
  53479. /**
  53480. * Parses a anisotropy Configuration from a serialized object.
  53481. * @param source - Serialized object.
  53482. * @param scene Defines the scene we are parsing for
  53483. * @param rootUrl Defines the rootUrl to load from
  53484. */
  53485. parse(source: any, scene: Scene, rootUrl: string): void;
  53486. }
  53487. }
  53488. declare module BABYLON {
  53489. /**
  53490. * @hidden
  53491. */
  53492. export interface IMaterialAnisotropicDefines {
  53493. ANISOTROPIC: boolean;
  53494. ANISOTROPIC_TEXTURE: boolean;
  53495. ANISOTROPIC_TEXTUREDIRECTUV: number;
  53496. MAINUV1: boolean;
  53497. _areTexturesDirty: boolean;
  53498. _needUVs: boolean;
  53499. }
  53500. /**
  53501. * Define the code related to the anisotropic parameters of the pbr material.
  53502. */
  53503. export class PBRAnisotropicConfiguration {
  53504. private _isEnabled;
  53505. /**
  53506. * Defines if the anisotropy is enabled in the material.
  53507. */
  53508. isEnabled: boolean;
  53509. /**
  53510. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  53511. */
  53512. intensity: number;
  53513. /**
  53514. * Defines if the effect is along the tangents, bitangents or in between.
  53515. * By default, the effect is "strectching" the highlights along the tangents.
  53516. */
  53517. direction: Vector2;
  53518. private _texture;
  53519. /**
  53520. * Stores the anisotropy values in a texture.
  53521. * rg is direction (like normal from -1 to 1)
  53522. * b is a intensity
  53523. */
  53524. texture: Nullable<BaseTexture>;
  53525. /** @hidden */
  53526. private _internalMarkAllSubMeshesAsTexturesDirty;
  53527. /** @hidden */
  53528. _markAllSubMeshesAsTexturesDirty(): void;
  53529. /**
  53530. * Instantiate a new istance of anisotropy configuration.
  53531. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53532. */
  53533. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53534. /**
  53535. * Specifies that the submesh is ready to be used.
  53536. * @param defines the list of "defines" to update.
  53537. * @param scene defines the scene the material belongs to.
  53538. * @returns - boolean indicating that the submesh is ready or not.
  53539. */
  53540. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  53541. /**
  53542. * Checks to see if a texture is used in the material.
  53543. * @param defines the list of "defines" to update.
  53544. * @param mesh the mesh we are preparing the defines for.
  53545. * @param scene defines the scene the material belongs to.
  53546. */
  53547. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  53548. /**
  53549. * Binds the material data.
  53550. * @param uniformBuffer defines the Uniform buffer to fill in.
  53551. * @param scene defines the scene the material belongs to.
  53552. * @param isFrozen defines wether the material is frozen or not.
  53553. */
  53554. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  53555. /**
  53556. * Checks to see if a texture is used in the material.
  53557. * @param texture - Base texture to use.
  53558. * @returns - Boolean specifying if a texture is used in the material.
  53559. */
  53560. hasTexture(texture: BaseTexture): boolean;
  53561. /**
  53562. * Returns an array of the actively used textures.
  53563. * @param activeTextures Array of BaseTextures
  53564. */
  53565. getActiveTextures(activeTextures: BaseTexture[]): void;
  53566. /**
  53567. * Returns the animatable textures.
  53568. * @param animatables Array of animatable textures.
  53569. */
  53570. getAnimatables(animatables: IAnimatable[]): void;
  53571. /**
  53572. * Disposes the resources of the material.
  53573. * @param forceDisposeTextures - Forces the disposal of all textures.
  53574. */
  53575. dispose(forceDisposeTextures?: boolean): void;
  53576. /**
  53577. * Get the current class name of the texture useful for serialization or dynamic coding.
  53578. * @returns "PBRAnisotropicConfiguration"
  53579. */
  53580. getClassName(): string;
  53581. /**
  53582. * Add fallbacks to the effect fallbacks list.
  53583. * @param defines defines the Base texture to use.
  53584. * @param fallbacks defines the current fallback list.
  53585. * @param currentRank defines the current fallback rank.
  53586. * @returns the new fallback rank.
  53587. */
  53588. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53589. /**
  53590. * Add the required uniforms to the current list.
  53591. * @param uniforms defines the current uniform list.
  53592. */
  53593. static AddUniforms(uniforms: string[]): void;
  53594. /**
  53595. * Add the required uniforms to the current buffer.
  53596. * @param uniformBuffer defines the current uniform buffer.
  53597. */
  53598. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53599. /**
  53600. * Add the required samplers to the current list.
  53601. * @param samplers defines the current sampler list.
  53602. */
  53603. static AddSamplers(samplers: string[]): void;
  53604. /**
  53605. * Makes a duplicate of the current configuration into another one.
  53606. * @param anisotropicConfiguration define the config where to copy the info
  53607. */
  53608. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  53609. /**
  53610. * Serializes this anisotropy configuration.
  53611. * @returns - An object with the serialized config.
  53612. */
  53613. serialize(): any;
  53614. /**
  53615. * Parses a anisotropy Configuration from a serialized object.
  53616. * @param source - Serialized object.
  53617. * @param scene Defines the scene we are parsing for
  53618. * @param rootUrl Defines the rootUrl to load from
  53619. */
  53620. parse(source: any, scene: Scene, rootUrl: string): void;
  53621. }
  53622. }
  53623. declare module BABYLON {
  53624. /**
  53625. * @hidden
  53626. */
  53627. export interface IMaterialBRDFDefines {
  53628. BRDF_V_HEIGHT_CORRELATED: boolean;
  53629. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53630. SPHERICAL_HARMONICS: boolean;
  53631. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53632. /** @hidden */
  53633. _areMiscDirty: boolean;
  53634. }
  53635. /**
  53636. * Define the code related to the BRDF parameters of the pbr material.
  53637. */
  53638. export class PBRBRDFConfiguration {
  53639. /**
  53640. * Default value used for the energy conservation.
  53641. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  53642. */
  53643. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  53644. /**
  53645. * Default value used for the Smith Visibility Height Correlated mode.
  53646. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  53647. */
  53648. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  53649. /**
  53650. * Default value used for the IBL diffuse part.
  53651. * This can help switching back to the polynomials mode globally which is a tiny bit
  53652. * less GPU intensive at the drawback of a lower quality.
  53653. */
  53654. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  53655. /**
  53656. * Default value used for activating energy conservation for the specular workflow.
  53657. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  53658. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  53659. */
  53660. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  53661. private _useEnergyConservation;
  53662. /**
  53663. * Defines if the material uses energy conservation.
  53664. */
  53665. useEnergyConservation: boolean;
  53666. private _useSmithVisibilityHeightCorrelated;
  53667. /**
  53668. * LEGACY Mode set to false
  53669. * Defines if the material uses height smith correlated visibility term.
  53670. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  53671. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  53672. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  53673. * Not relying on height correlated will also disable energy conservation.
  53674. */
  53675. useSmithVisibilityHeightCorrelated: boolean;
  53676. private _useSphericalHarmonics;
  53677. /**
  53678. * LEGACY Mode set to false
  53679. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  53680. * diffuse part of the IBL.
  53681. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  53682. * to the ground truth.
  53683. */
  53684. useSphericalHarmonics: boolean;
  53685. private _useSpecularGlossinessInputEnergyConservation;
  53686. /**
  53687. * Defines if the material uses energy conservation, when the specular workflow is active.
  53688. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  53689. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  53690. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  53691. */
  53692. useSpecularGlossinessInputEnergyConservation: boolean;
  53693. /** @hidden */
  53694. private _internalMarkAllSubMeshesAsMiscDirty;
  53695. /** @hidden */
  53696. _markAllSubMeshesAsMiscDirty(): void;
  53697. /**
  53698. * Instantiate a new istance of clear coat configuration.
  53699. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  53700. */
  53701. constructor(markAllSubMeshesAsMiscDirty: () => void);
  53702. /**
  53703. * Checks to see if a texture is used in the material.
  53704. * @param defines the list of "defines" to update.
  53705. */
  53706. prepareDefines(defines: IMaterialBRDFDefines): void;
  53707. /**
  53708. * Get the current class name of the texture useful for serialization or dynamic coding.
  53709. * @returns "PBRClearCoatConfiguration"
  53710. */
  53711. getClassName(): string;
  53712. /**
  53713. * Makes a duplicate of the current configuration into another one.
  53714. * @param brdfConfiguration define the config where to copy the info
  53715. */
  53716. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  53717. /**
  53718. * Serializes this BRDF configuration.
  53719. * @returns - An object with the serialized config.
  53720. */
  53721. serialize(): any;
  53722. /**
  53723. * Parses a anisotropy Configuration from a serialized object.
  53724. * @param source - Serialized object.
  53725. * @param scene Defines the scene we are parsing for
  53726. * @param rootUrl Defines the rootUrl to load from
  53727. */
  53728. parse(source: any, scene: Scene, rootUrl: string): void;
  53729. }
  53730. }
  53731. declare module BABYLON {
  53732. /**
  53733. * @hidden
  53734. */
  53735. export interface IMaterialSheenDefines {
  53736. SHEEN: boolean;
  53737. SHEEN_TEXTURE: boolean;
  53738. SHEEN_TEXTUREDIRECTUV: number;
  53739. SHEEN_LINKWITHALBEDO: boolean;
  53740. SHEEN_ROUGHNESS: boolean;
  53741. SHEEN_ALBEDOSCALING: boolean;
  53742. /** @hidden */
  53743. _areTexturesDirty: boolean;
  53744. }
  53745. /**
  53746. * Define the code related to the Sheen parameters of the pbr material.
  53747. */
  53748. export class PBRSheenConfiguration {
  53749. private _isEnabled;
  53750. /**
  53751. * Defines if the material uses sheen.
  53752. */
  53753. isEnabled: boolean;
  53754. private _linkSheenWithAlbedo;
  53755. /**
  53756. * Defines if the sheen is linked to the sheen color.
  53757. */
  53758. linkSheenWithAlbedo: boolean;
  53759. /**
  53760. * Defines the sheen intensity.
  53761. */
  53762. intensity: number;
  53763. /**
  53764. * Defines the sheen color.
  53765. */
  53766. color: Color3;
  53767. private _texture;
  53768. /**
  53769. * Stores the sheen tint values in a texture.
  53770. * rgb is tint
  53771. * a is a intensity
  53772. */
  53773. texture: Nullable<BaseTexture>;
  53774. private _roughness;
  53775. /**
  53776. * Defines the sheen roughness.
  53777. * It is not taken into account if linkSheenWithAlbedo is true.
  53778. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  53779. */
  53780. roughness: Nullable<number>;
  53781. private _albedoScaling;
  53782. /**
  53783. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  53784. * It allows the strength of the sheen effect to not depend on the base color of the material,
  53785. * making it easier to setup and tweak the effect
  53786. */
  53787. albedoScaling: boolean;
  53788. /** @hidden */
  53789. private _internalMarkAllSubMeshesAsTexturesDirty;
  53790. /** @hidden */
  53791. _markAllSubMeshesAsTexturesDirty(): void;
  53792. /**
  53793. * Instantiate a new istance of clear coat configuration.
  53794. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53795. */
  53796. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53797. /**
  53798. * Specifies that the submesh is ready to be used.
  53799. * @param defines the list of "defines" to update.
  53800. * @param scene defines the scene the material belongs to.
  53801. * @returns - boolean indicating that the submesh is ready or not.
  53802. */
  53803. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  53804. /**
  53805. * Checks to see if a texture is used in the material.
  53806. * @param defines the list of "defines" to update.
  53807. * @param scene defines the scene the material belongs to.
  53808. */
  53809. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  53810. /**
  53811. * Binds the material data.
  53812. * @param uniformBuffer defines the Uniform buffer to fill in.
  53813. * @param scene defines the scene the material belongs to.
  53814. * @param isFrozen defines wether the material is frozen or not.
  53815. */
  53816. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  53817. /**
  53818. * Checks to see if a texture is used in the material.
  53819. * @param texture - Base texture to use.
  53820. * @returns - Boolean specifying if a texture is used in the material.
  53821. */
  53822. hasTexture(texture: BaseTexture): boolean;
  53823. /**
  53824. * Returns an array of the actively used textures.
  53825. * @param activeTextures Array of BaseTextures
  53826. */
  53827. getActiveTextures(activeTextures: BaseTexture[]): void;
  53828. /**
  53829. * Returns the animatable textures.
  53830. * @param animatables Array of animatable textures.
  53831. */
  53832. getAnimatables(animatables: IAnimatable[]): void;
  53833. /**
  53834. * Disposes the resources of the material.
  53835. * @param forceDisposeTextures - Forces the disposal of all textures.
  53836. */
  53837. dispose(forceDisposeTextures?: boolean): void;
  53838. /**
  53839. * Get the current class name of the texture useful for serialization or dynamic coding.
  53840. * @returns "PBRSheenConfiguration"
  53841. */
  53842. getClassName(): string;
  53843. /**
  53844. * Add fallbacks to the effect fallbacks list.
  53845. * @param defines defines the Base texture to use.
  53846. * @param fallbacks defines the current fallback list.
  53847. * @param currentRank defines the current fallback rank.
  53848. * @returns the new fallback rank.
  53849. */
  53850. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53851. /**
  53852. * Add the required uniforms to the current list.
  53853. * @param uniforms defines the current uniform list.
  53854. */
  53855. static AddUniforms(uniforms: string[]): void;
  53856. /**
  53857. * Add the required uniforms to the current buffer.
  53858. * @param uniformBuffer defines the current uniform buffer.
  53859. */
  53860. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53861. /**
  53862. * Add the required samplers to the current list.
  53863. * @param samplers defines the current sampler list.
  53864. */
  53865. static AddSamplers(samplers: string[]): void;
  53866. /**
  53867. * Makes a duplicate of the current configuration into another one.
  53868. * @param sheenConfiguration define the config where to copy the info
  53869. */
  53870. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  53871. /**
  53872. * Serializes this BRDF configuration.
  53873. * @returns - An object with the serialized config.
  53874. */
  53875. serialize(): any;
  53876. /**
  53877. * Parses a anisotropy Configuration from a serialized object.
  53878. * @param source - Serialized object.
  53879. * @param scene Defines the scene we are parsing for
  53880. * @param rootUrl Defines the rootUrl to load from
  53881. */
  53882. parse(source: any, scene: Scene, rootUrl: string): void;
  53883. }
  53884. }
  53885. declare module BABYLON {
  53886. /**
  53887. * @hidden
  53888. */
  53889. export interface IMaterialSubSurfaceDefines {
  53890. SUBSURFACE: boolean;
  53891. SS_REFRACTION: boolean;
  53892. SS_TRANSLUCENCY: boolean;
  53893. SS_SCATERRING: boolean;
  53894. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53895. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53896. SS_REFRACTIONMAP_3D: boolean;
  53897. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53898. SS_LODINREFRACTIONALPHA: boolean;
  53899. SS_GAMMAREFRACTION: boolean;
  53900. SS_RGBDREFRACTION: boolean;
  53901. SS_LINEARSPECULARREFRACTION: boolean;
  53902. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53903. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53904. /** @hidden */
  53905. _areTexturesDirty: boolean;
  53906. }
  53907. /**
  53908. * Define the code related to the sub surface parameters of the pbr material.
  53909. */
  53910. export class PBRSubSurfaceConfiguration {
  53911. private _isRefractionEnabled;
  53912. /**
  53913. * Defines if the refraction is enabled in the material.
  53914. */
  53915. isRefractionEnabled: boolean;
  53916. private _isTranslucencyEnabled;
  53917. /**
  53918. * Defines if the translucency is enabled in the material.
  53919. */
  53920. isTranslucencyEnabled: boolean;
  53921. private _isScatteringEnabled;
  53922. /**
  53923. * Defines the refraction intensity of the material.
  53924. * The refraction when enabled replaces the Diffuse part of the material.
  53925. * The intensity helps transitionning between diffuse and refraction.
  53926. */
  53927. refractionIntensity: number;
  53928. /**
  53929. * Defines the translucency intensity of the material.
  53930. * When translucency has been enabled, this defines how much of the "translucency"
  53931. * is addded to the diffuse part of the material.
  53932. */
  53933. translucencyIntensity: number;
  53934. /**
  53935. * Defines the scattering intensity of the material.
  53936. * When scattering has been enabled, this defines how much of the "scattered light"
  53937. * is addded to the diffuse part of the material.
  53938. */
  53939. scatteringIntensity: number;
  53940. private _thicknessTexture;
  53941. /**
  53942. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  53943. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  53944. * 0 would mean minimumThickness
  53945. * 1 would mean maximumThickness
  53946. * The other channels might be use as a mask to vary the different effects intensity.
  53947. */
  53948. thicknessTexture: Nullable<BaseTexture>;
  53949. private _refractionTexture;
  53950. /**
  53951. * Defines the texture to use for refraction.
  53952. */
  53953. refractionTexture: Nullable<BaseTexture>;
  53954. private _indexOfRefraction;
  53955. /**
  53956. * Index of refraction of the material base layer.
  53957. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  53958. *
  53959. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  53960. *
  53961. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  53962. */
  53963. indexOfRefraction: number;
  53964. private _invertRefractionY;
  53965. /**
  53966. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  53967. */
  53968. invertRefractionY: boolean;
  53969. private _linkRefractionWithTransparency;
  53970. /**
  53971. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  53972. * Materials half opaque for instance using refraction could benefit from this control.
  53973. */
  53974. linkRefractionWithTransparency: boolean;
  53975. /**
  53976. * Defines the minimum thickness stored in the thickness map.
  53977. * If no thickness map is defined, this value will be used to simulate thickness.
  53978. */
  53979. minimumThickness: number;
  53980. /**
  53981. * Defines the maximum thickness stored in the thickness map.
  53982. */
  53983. maximumThickness: number;
  53984. /**
  53985. * Defines the volume tint of the material.
  53986. * This is used for both translucency and scattering.
  53987. */
  53988. tintColor: Color3;
  53989. /**
  53990. * Defines the distance at which the tint color should be found in the media.
  53991. * This is used for refraction only.
  53992. */
  53993. tintColorAtDistance: number;
  53994. /**
  53995. * Defines how far each channel transmit through the media.
  53996. * It is defined as a color to simplify it selection.
  53997. */
  53998. diffusionDistance: Color3;
  53999. private _useMaskFromThicknessTexture;
  54000. /**
  54001. * Stores the intensity of the different subsurface effects in the thickness texture.
  54002. * * the green channel is the translucency intensity.
  54003. * * the blue channel is the scattering intensity.
  54004. * * the alpha channel is the refraction intensity.
  54005. */
  54006. useMaskFromThicknessTexture: boolean;
  54007. /** @hidden */
  54008. private _internalMarkAllSubMeshesAsTexturesDirty;
  54009. /** @hidden */
  54010. _markAllSubMeshesAsTexturesDirty(): void;
  54011. /**
  54012. * Instantiate a new istance of sub surface configuration.
  54013. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54014. */
  54015. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54016. /**
  54017. * Gets wehter the submesh is ready to be used or not.
  54018. * @param defines the list of "defines" to update.
  54019. * @param scene defines the scene the material belongs to.
  54020. * @returns - boolean indicating that the submesh is ready or not.
  54021. */
  54022. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  54023. /**
  54024. * Checks to see if a texture is used in the material.
  54025. * @param defines the list of "defines" to update.
  54026. * @param scene defines the scene to the material belongs to.
  54027. */
  54028. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  54029. /**
  54030. * Binds the material data.
  54031. * @param uniformBuffer defines the Uniform buffer to fill in.
  54032. * @param scene defines the scene the material belongs to.
  54033. * @param engine defines the engine the material belongs to.
  54034. * @param isFrozen defines wether the material is frozen or not.
  54035. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  54036. */
  54037. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  54038. /**
  54039. * Unbinds the material from the mesh.
  54040. * @param activeEffect defines the effect that should be unbound from.
  54041. * @returns true if unbound, otherwise false
  54042. */
  54043. unbind(activeEffect: Effect): boolean;
  54044. /**
  54045. * Returns the texture used for refraction or null if none is used.
  54046. * @param scene defines the scene the material belongs to.
  54047. * @returns - Refraction texture if present. If no refraction texture and refraction
  54048. * is linked with transparency, returns environment texture. Otherwise, returns null.
  54049. */
  54050. private _getRefractionTexture;
  54051. /**
  54052. * Returns true if alpha blending should be disabled.
  54053. */
  54054. get disableAlphaBlending(): boolean;
  54055. /**
  54056. * Fills the list of render target textures.
  54057. * @param renderTargets the list of render targets to update
  54058. */
  54059. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  54060. /**
  54061. * Checks to see if a texture is used in the material.
  54062. * @param texture - Base texture to use.
  54063. * @returns - Boolean specifying if a texture is used in the material.
  54064. */
  54065. hasTexture(texture: BaseTexture): boolean;
  54066. /**
  54067. * Gets a boolean indicating that current material needs to register RTT
  54068. * @returns true if this uses a render target otherwise false.
  54069. */
  54070. hasRenderTargetTextures(): boolean;
  54071. /**
  54072. * Returns an array of the actively used textures.
  54073. * @param activeTextures Array of BaseTextures
  54074. */
  54075. getActiveTextures(activeTextures: BaseTexture[]): void;
  54076. /**
  54077. * Returns the animatable textures.
  54078. * @param animatables Array of animatable textures.
  54079. */
  54080. getAnimatables(animatables: IAnimatable[]): void;
  54081. /**
  54082. * Disposes the resources of the material.
  54083. * @param forceDisposeTextures - Forces the disposal of all textures.
  54084. */
  54085. dispose(forceDisposeTextures?: boolean): void;
  54086. /**
  54087. * Get the current class name of the texture useful for serialization or dynamic coding.
  54088. * @returns "PBRSubSurfaceConfiguration"
  54089. */
  54090. getClassName(): string;
  54091. /**
  54092. * Add fallbacks to the effect fallbacks list.
  54093. * @param defines defines the Base texture to use.
  54094. * @param fallbacks defines the current fallback list.
  54095. * @param currentRank defines the current fallback rank.
  54096. * @returns the new fallback rank.
  54097. */
  54098. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54099. /**
  54100. * Add the required uniforms to the current list.
  54101. * @param uniforms defines the current uniform list.
  54102. */
  54103. static AddUniforms(uniforms: string[]): void;
  54104. /**
  54105. * Add the required samplers to the current list.
  54106. * @param samplers defines the current sampler list.
  54107. */
  54108. static AddSamplers(samplers: string[]): void;
  54109. /**
  54110. * Add the required uniforms to the current buffer.
  54111. * @param uniformBuffer defines the current uniform buffer.
  54112. */
  54113. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54114. /**
  54115. * Makes a duplicate of the current configuration into another one.
  54116. * @param configuration define the config where to copy the info
  54117. */
  54118. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  54119. /**
  54120. * Serializes this Sub Surface configuration.
  54121. * @returns - An object with the serialized config.
  54122. */
  54123. serialize(): any;
  54124. /**
  54125. * Parses a anisotropy Configuration from a serialized object.
  54126. * @param source - Serialized object.
  54127. * @param scene Defines the scene we are parsing for
  54128. * @param rootUrl Defines the rootUrl to load from
  54129. */
  54130. parse(source: any, scene: Scene, rootUrl: string): void;
  54131. }
  54132. }
  54133. declare module BABYLON {
  54134. /** @hidden */
  54135. export var pbrFragmentDeclaration: {
  54136. name: string;
  54137. shader: string;
  54138. };
  54139. }
  54140. declare module BABYLON {
  54141. /** @hidden */
  54142. export var pbrUboDeclaration: {
  54143. name: string;
  54144. shader: string;
  54145. };
  54146. }
  54147. declare module BABYLON {
  54148. /** @hidden */
  54149. export var pbrFragmentExtraDeclaration: {
  54150. name: string;
  54151. shader: string;
  54152. };
  54153. }
  54154. declare module BABYLON {
  54155. /** @hidden */
  54156. export var pbrFragmentSamplersDeclaration: {
  54157. name: string;
  54158. shader: string;
  54159. };
  54160. }
  54161. declare module BABYLON {
  54162. /** @hidden */
  54163. export var importanceSampling: {
  54164. name: string;
  54165. shader: string;
  54166. };
  54167. }
  54168. declare module BABYLON {
  54169. /** @hidden */
  54170. export var pbrHelperFunctions: {
  54171. name: string;
  54172. shader: string;
  54173. };
  54174. }
  54175. declare module BABYLON {
  54176. /** @hidden */
  54177. export var harmonicsFunctions: {
  54178. name: string;
  54179. shader: string;
  54180. };
  54181. }
  54182. declare module BABYLON {
  54183. /** @hidden */
  54184. export var pbrDirectLightingSetupFunctions: {
  54185. name: string;
  54186. shader: string;
  54187. };
  54188. }
  54189. declare module BABYLON {
  54190. /** @hidden */
  54191. export var pbrDirectLightingFalloffFunctions: {
  54192. name: string;
  54193. shader: string;
  54194. };
  54195. }
  54196. declare module BABYLON {
  54197. /** @hidden */
  54198. export var pbrBRDFFunctions: {
  54199. name: string;
  54200. shader: string;
  54201. };
  54202. }
  54203. declare module BABYLON {
  54204. /** @hidden */
  54205. export var hdrFilteringFunctions: {
  54206. name: string;
  54207. shader: string;
  54208. };
  54209. }
  54210. declare module BABYLON {
  54211. /** @hidden */
  54212. export var pbrDirectLightingFunctions: {
  54213. name: string;
  54214. shader: string;
  54215. };
  54216. }
  54217. declare module BABYLON {
  54218. /** @hidden */
  54219. export var pbrIBLFunctions: {
  54220. name: string;
  54221. shader: string;
  54222. };
  54223. }
  54224. declare module BABYLON {
  54225. /** @hidden */
  54226. export var pbrBlockAlbedoOpacity: {
  54227. name: string;
  54228. shader: string;
  54229. };
  54230. }
  54231. declare module BABYLON {
  54232. /** @hidden */
  54233. export var pbrBlockReflectivity: {
  54234. name: string;
  54235. shader: string;
  54236. };
  54237. }
  54238. declare module BABYLON {
  54239. /** @hidden */
  54240. export var pbrBlockAmbientOcclusion: {
  54241. name: string;
  54242. shader: string;
  54243. };
  54244. }
  54245. declare module BABYLON {
  54246. /** @hidden */
  54247. export var pbrBlockAlphaFresnel: {
  54248. name: string;
  54249. shader: string;
  54250. };
  54251. }
  54252. declare module BABYLON {
  54253. /** @hidden */
  54254. export var pbrBlockAnisotropic: {
  54255. name: string;
  54256. shader: string;
  54257. };
  54258. }
  54259. declare module BABYLON {
  54260. /** @hidden */
  54261. export var pbrBlockReflection: {
  54262. name: string;
  54263. shader: string;
  54264. };
  54265. }
  54266. declare module BABYLON {
  54267. /** @hidden */
  54268. export var pbrBlockSheen: {
  54269. name: string;
  54270. shader: string;
  54271. };
  54272. }
  54273. declare module BABYLON {
  54274. /** @hidden */
  54275. export var pbrBlockClearcoat: {
  54276. name: string;
  54277. shader: string;
  54278. };
  54279. }
  54280. declare module BABYLON {
  54281. /** @hidden */
  54282. export var pbrBlockSubSurface: {
  54283. name: string;
  54284. shader: string;
  54285. };
  54286. }
  54287. declare module BABYLON {
  54288. /** @hidden */
  54289. export var pbrBlockNormalGeometric: {
  54290. name: string;
  54291. shader: string;
  54292. };
  54293. }
  54294. declare module BABYLON {
  54295. /** @hidden */
  54296. export var pbrBlockNormalFinal: {
  54297. name: string;
  54298. shader: string;
  54299. };
  54300. }
  54301. declare module BABYLON {
  54302. /** @hidden */
  54303. export var pbrBlockGeometryInfo: {
  54304. name: string;
  54305. shader: string;
  54306. };
  54307. }
  54308. declare module BABYLON {
  54309. /** @hidden */
  54310. export var pbrBlockReflectance0: {
  54311. name: string;
  54312. shader: string;
  54313. };
  54314. }
  54315. declare module BABYLON {
  54316. /** @hidden */
  54317. export var pbrBlockReflectance: {
  54318. name: string;
  54319. shader: string;
  54320. };
  54321. }
  54322. declare module BABYLON {
  54323. /** @hidden */
  54324. export var pbrBlockDirectLighting: {
  54325. name: string;
  54326. shader: string;
  54327. };
  54328. }
  54329. declare module BABYLON {
  54330. /** @hidden */
  54331. export var pbrBlockFinalLitComponents: {
  54332. name: string;
  54333. shader: string;
  54334. };
  54335. }
  54336. declare module BABYLON {
  54337. /** @hidden */
  54338. export var pbrBlockFinalUnlitComponents: {
  54339. name: string;
  54340. shader: string;
  54341. };
  54342. }
  54343. declare module BABYLON {
  54344. /** @hidden */
  54345. export var pbrBlockFinalColorComposition: {
  54346. name: string;
  54347. shader: string;
  54348. };
  54349. }
  54350. declare module BABYLON {
  54351. /** @hidden */
  54352. export var pbrBlockImageProcessing: {
  54353. name: string;
  54354. shader: string;
  54355. };
  54356. }
  54357. declare module BABYLON {
  54358. /** @hidden */
  54359. export var pbrDebug: {
  54360. name: string;
  54361. shader: string;
  54362. };
  54363. }
  54364. declare module BABYLON {
  54365. /** @hidden */
  54366. export var pbrPixelShader: {
  54367. name: string;
  54368. shader: string;
  54369. };
  54370. }
  54371. declare module BABYLON {
  54372. /** @hidden */
  54373. export var pbrVertexDeclaration: {
  54374. name: string;
  54375. shader: string;
  54376. };
  54377. }
  54378. declare module BABYLON {
  54379. /** @hidden */
  54380. export var pbrVertexShader: {
  54381. name: string;
  54382. shader: string;
  54383. };
  54384. }
  54385. declare module BABYLON {
  54386. /**
  54387. * Manages the defines for the PBR Material.
  54388. * @hidden
  54389. */
  54390. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  54391. PBR: boolean;
  54392. NUM_SAMPLES: string;
  54393. REALTIME_FILTERING: boolean;
  54394. MAINUV1: boolean;
  54395. MAINUV2: boolean;
  54396. UV1: boolean;
  54397. UV2: boolean;
  54398. ALBEDO: boolean;
  54399. GAMMAALBEDO: boolean;
  54400. ALBEDODIRECTUV: number;
  54401. VERTEXCOLOR: boolean;
  54402. AMBIENT: boolean;
  54403. AMBIENTDIRECTUV: number;
  54404. AMBIENTINGRAYSCALE: boolean;
  54405. OPACITY: boolean;
  54406. VERTEXALPHA: boolean;
  54407. OPACITYDIRECTUV: number;
  54408. OPACITYRGB: boolean;
  54409. ALPHATEST: boolean;
  54410. DEPTHPREPASS: boolean;
  54411. ALPHABLEND: boolean;
  54412. ALPHAFROMALBEDO: boolean;
  54413. ALPHATESTVALUE: string;
  54414. SPECULAROVERALPHA: boolean;
  54415. RADIANCEOVERALPHA: boolean;
  54416. ALPHAFRESNEL: boolean;
  54417. LINEARALPHAFRESNEL: boolean;
  54418. PREMULTIPLYALPHA: boolean;
  54419. EMISSIVE: boolean;
  54420. EMISSIVEDIRECTUV: number;
  54421. REFLECTIVITY: boolean;
  54422. REFLECTIVITYDIRECTUV: number;
  54423. SPECULARTERM: boolean;
  54424. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  54425. MICROSURFACEAUTOMATIC: boolean;
  54426. LODBASEDMICROSFURACE: boolean;
  54427. MICROSURFACEMAP: boolean;
  54428. MICROSURFACEMAPDIRECTUV: number;
  54429. METALLICWORKFLOW: boolean;
  54430. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  54431. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  54432. METALLNESSSTOREINMETALMAPBLUE: boolean;
  54433. AOSTOREINMETALMAPRED: boolean;
  54434. METALLIC_REFLECTANCE: boolean;
  54435. METALLIC_REFLECTANCEDIRECTUV: number;
  54436. ENVIRONMENTBRDF: boolean;
  54437. ENVIRONMENTBRDF_RGBD: boolean;
  54438. NORMAL: boolean;
  54439. TANGENT: boolean;
  54440. BUMP: boolean;
  54441. BUMPDIRECTUV: number;
  54442. OBJECTSPACE_NORMALMAP: boolean;
  54443. PARALLAX: boolean;
  54444. PARALLAXOCCLUSION: boolean;
  54445. NORMALXYSCALE: boolean;
  54446. LIGHTMAP: boolean;
  54447. LIGHTMAPDIRECTUV: number;
  54448. USELIGHTMAPASSHADOWMAP: boolean;
  54449. GAMMALIGHTMAP: boolean;
  54450. RGBDLIGHTMAP: boolean;
  54451. REFLECTION: boolean;
  54452. REFLECTIONMAP_3D: boolean;
  54453. REFLECTIONMAP_SPHERICAL: boolean;
  54454. REFLECTIONMAP_PLANAR: boolean;
  54455. REFLECTIONMAP_CUBIC: boolean;
  54456. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  54457. REFLECTIONMAP_PROJECTION: boolean;
  54458. REFLECTIONMAP_SKYBOX: boolean;
  54459. REFLECTIONMAP_EXPLICIT: boolean;
  54460. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  54461. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  54462. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  54463. INVERTCUBICMAP: boolean;
  54464. USESPHERICALFROMREFLECTIONMAP: boolean;
  54465. USEIRRADIANCEMAP: boolean;
  54466. SPHERICAL_HARMONICS: boolean;
  54467. USESPHERICALINVERTEX: boolean;
  54468. REFLECTIONMAP_OPPOSITEZ: boolean;
  54469. LODINREFLECTIONALPHA: boolean;
  54470. GAMMAREFLECTION: boolean;
  54471. RGBDREFLECTION: boolean;
  54472. LINEARSPECULARREFLECTION: boolean;
  54473. RADIANCEOCCLUSION: boolean;
  54474. HORIZONOCCLUSION: boolean;
  54475. INSTANCES: boolean;
  54476. NUM_BONE_INFLUENCERS: number;
  54477. BonesPerMesh: number;
  54478. BONETEXTURE: boolean;
  54479. NONUNIFORMSCALING: boolean;
  54480. MORPHTARGETS: boolean;
  54481. MORPHTARGETS_NORMAL: boolean;
  54482. MORPHTARGETS_TANGENT: boolean;
  54483. MORPHTARGETS_UV: boolean;
  54484. NUM_MORPH_INFLUENCERS: number;
  54485. IMAGEPROCESSING: boolean;
  54486. VIGNETTE: boolean;
  54487. VIGNETTEBLENDMODEMULTIPLY: boolean;
  54488. VIGNETTEBLENDMODEOPAQUE: boolean;
  54489. TONEMAPPING: boolean;
  54490. TONEMAPPING_ACES: boolean;
  54491. CONTRAST: boolean;
  54492. COLORCURVES: boolean;
  54493. COLORGRADING: boolean;
  54494. COLORGRADING3D: boolean;
  54495. SAMPLER3DGREENDEPTH: boolean;
  54496. SAMPLER3DBGRMAP: boolean;
  54497. IMAGEPROCESSINGPOSTPROCESS: boolean;
  54498. EXPOSURE: boolean;
  54499. MULTIVIEW: boolean;
  54500. USEPHYSICALLIGHTFALLOFF: boolean;
  54501. USEGLTFLIGHTFALLOFF: boolean;
  54502. TWOSIDEDLIGHTING: boolean;
  54503. SHADOWFLOAT: boolean;
  54504. CLIPPLANE: boolean;
  54505. CLIPPLANE2: boolean;
  54506. CLIPPLANE3: boolean;
  54507. CLIPPLANE4: boolean;
  54508. CLIPPLANE5: boolean;
  54509. CLIPPLANE6: boolean;
  54510. POINTSIZE: boolean;
  54511. FOG: boolean;
  54512. LOGARITHMICDEPTH: boolean;
  54513. FORCENORMALFORWARD: boolean;
  54514. SPECULARAA: boolean;
  54515. CLEARCOAT: boolean;
  54516. CLEARCOAT_DEFAULTIOR: boolean;
  54517. CLEARCOAT_TEXTURE: boolean;
  54518. CLEARCOAT_TEXTUREDIRECTUV: number;
  54519. CLEARCOAT_BUMP: boolean;
  54520. CLEARCOAT_BUMPDIRECTUV: number;
  54521. CLEARCOAT_TINT: boolean;
  54522. CLEARCOAT_TINT_TEXTURE: boolean;
  54523. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  54524. ANISOTROPIC: boolean;
  54525. ANISOTROPIC_TEXTURE: boolean;
  54526. ANISOTROPIC_TEXTUREDIRECTUV: number;
  54527. BRDF_V_HEIGHT_CORRELATED: boolean;
  54528. MS_BRDF_ENERGY_CONSERVATION: boolean;
  54529. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  54530. SHEEN: boolean;
  54531. SHEEN_TEXTURE: boolean;
  54532. SHEEN_TEXTUREDIRECTUV: number;
  54533. SHEEN_LINKWITHALBEDO: boolean;
  54534. SHEEN_ROUGHNESS: boolean;
  54535. SHEEN_ALBEDOSCALING: boolean;
  54536. SUBSURFACE: boolean;
  54537. SS_REFRACTION: boolean;
  54538. SS_TRANSLUCENCY: boolean;
  54539. SS_SCATERRING: boolean;
  54540. SS_THICKNESSANDMASK_TEXTURE: boolean;
  54541. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  54542. SS_REFRACTIONMAP_3D: boolean;
  54543. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  54544. SS_LODINREFRACTIONALPHA: boolean;
  54545. SS_GAMMAREFRACTION: boolean;
  54546. SS_RGBDREFRACTION: boolean;
  54547. SS_LINEARSPECULARREFRACTION: boolean;
  54548. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  54549. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  54550. UNLIT: boolean;
  54551. DEBUGMODE: number;
  54552. /**
  54553. * Initializes the PBR Material defines.
  54554. */
  54555. constructor();
  54556. /**
  54557. * Resets the PBR Material defines.
  54558. */
  54559. reset(): void;
  54560. }
  54561. /**
  54562. * The Physically based material base class of BJS.
  54563. *
  54564. * This offers the main features of a standard PBR material.
  54565. * For more information, please refer to the documentation :
  54566. * https://doc.babylonjs.com/how_to/physically_based_rendering
  54567. */
  54568. export abstract class PBRBaseMaterial extends PushMaterial {
  54569. /**
  54570. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  54571. */
  54572. static readonly PBRMATERIAL_OPAQUE: number;
  54573. /**
  54574. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  54575. */
  54576. static readonly PBRMATERIAL_ALPHATEST: number;
  54577. /**
  54578. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54579. */
  54580. static readonly PBRMATERIAL_ALPHABLEND: number;
  54581. /**
  54582. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54583. * They are also discarded below the alpha cutoff threshold to improve performances.
  54584. */
  54585. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  54586. /**
  54587. * Defines the default value of how much AO map is occluding the analytical lights
  54588. * (point spot...).
  54589. */
  54590. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  54591. /**
  54592. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  54593. */
  54594. static readonly LIGHTFALLOFF_PHYSICAL: number;
  54595. /**
  54596. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  54597. * to enhance interoperability with other engines.
  54598. */
  54599. static readonly LIGHTFALLOFF_GLTF: number;
  54600. /**
  54601. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  54602. * to enhance interoperability with other materials.
  54603. */
  54604. static readonly LIGHTFALLOFF_STANDARD: number;
  54605. /**
  54606. * Intensity of the direct lights e.g. the four lights available in your scene.
  54607. * This impacts both the direct diffuse and specular highlights.
  54608. */
  54609. protected _directIntensity: number;
  54610. /**
  54611. * Intensity of the emissive part of the material.
  54612. * This helps controlling the emissive effect without modifying the emissive color.
  54613. */
  54614. protected _emissiveIntensity: number;
  54615. /**
  54616. * Intensity of the environment e.g. how much the environment will light the object
  54617. * either through harmonics for rough material or through the refelction for shiny ones.
  54618. */
  54619. protected _environmentIntensity: number;
  54620. /**
  54621. * This is a special control allowing the reduction of the specular highlights coming from the
  54622. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  54623. */
  54624. protected _specularIntensity: number;
  54625. /**
  54626. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  54627. */
  54628. private _lightingInfos;
  54629. /**
  54630. * Debug Control allowing disabling the bump map on this material.
  54631. */
  54632. protected _disableBumpMap: boolean;
  54633. /**
  54634. * AKA Diffuse Texture in standard nomenclature.
  54635. */
  54636. protected _albedoTexture: Nullable<BaseTexture>;
  54637. /**
  54638. * AKA Occlusion Texture in other nomenclature.
  54639. */
  54640. protected _ambientTexture: Nullable<BaseTexture>;
  54641. /**
  54642. * AKA Occlusion Texture Intensity in other nomenclature.
  54643. */
  54644. protected _ambientTextureStrength: number;
  54645. /**
  54646. * Defines how much the AO map is occluding the analytical lights (point spot...).
  54647. * 1 means it completely occludes it
  54648. * 0 mean it has no impact
  54649. */
  54650. protected _ambientTextureImpactOnAnalyticalLights: number;
  54651. /**
  54652. * Stores the alpha values in a texture.
  54653. */
  54654. protected _opacityTexture: Nullable<BaseTexture>;
  54655. /**
  54656. * Stores the reflection values in a texture.
  54657. */
  54658. protected _reflectionTexture: Nullable<BaseTexture>;
  54659. /**
  54660. * Stores the emissive values in a texture.
  54661. */
  54662. protected _emissiveTexture: Nullable<BaseTexture>;
  54663. /**
  54664. * AKA Specular texture in other nomenclature.
  54665. */
  54666. protected _reflectivityTexture: Nullable<BaseTexture>;
  54667. /**
  54668. * Used to switch from specular/glossiness to metallic/roughness workflow.
  54669. */
  54670. protected _metallicTexture: Nullable<BaseTexture>;
  54671. /**
  54672. * Specifies the metallic scalar of the metallic/roughness workflow.
  54673. * Can also be used to scale the metalness values of the metallic texture.
  54674. */
  54675. protected _metallic: Nullable<number>;
  54676. /**
  54677. * Specifies the roughness scalar of the metallic/roughness workflow.
  54678. * Can also be used to scale the roughness values of the metallic texture.
  54679. */
  54680. protected _roughness: Nullable<number>;
  54681. /**
  54682. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  54683. * By default the indexOfrefraction is used to compute F0;
  54684. *
  54685. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  54686. *
  54687. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  54688. * F90 = metallicReflectanceColor;
  54689. */
  54690. protected _metallicF0Factor: number;
  54691. /**
  54692. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  54693. * By default the F90 is always 1;
  54694. *
  54695. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  54696. *
  54697. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  54698. * F90 = metallicReflectanceColor;
  54699. */
  54700. protected _metallicReflectanceColor: Color3;
  54701. /**
  54702. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  54703. * This is multiply against the scalar values defined in the material.
  54704. */
  54705. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  54706. /**
  54707. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  54708. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  54709. */
  54710. protected _microSurfaceTexture: Nullable<BaseTexture>;
  54711. /**
  54712. * Stores surface normal data used to displace a mesh in a texture.
  54713. */
  54714. protected _bumpTexture: Nullable<BaseTexture>;
  54715. /**
  54716. * Stores the pre-calculated light information of a mesh in a texture.
  54717. */
  54718. protected _lightmapTexture: Nullable<BaseTexture>;
  54719. /**
  54720. * The color of a material in ambient lighting.
  54721. */
  54722. protected _ambientColor: Color3;
  54723. /**
  54724. * AKA Diffuse Color in other nomenclature.
  54725. */
  54726. protected _albedoColor: Color3;
  54727. /**
  54728. * AKA Specular Color in other nomenclature.
  54729. */
  54730. protected _reflectivityColor: Color3;
  54731. /**
  54732. * The color applied when light is reflected from a material.
  54733. */
  54734. protected _reflectionColor: Color3;
  54735. /**
  54736. * The color applied when light is emitted from a material.
  54737. */
  54738. protected _emissiveColor: Color3;
  54739. /**
  54740. * AKA Glossiness in other nomenclature.
  54741. */
  54742. protected _microSurface: number;
  54743. /**
  54744. * Specifies that the material will use the light map as a show map.
  54745. */
  54746. protected _useLightmapAsShadowmap: boolean;
  54747. /**
  54748. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54749. * makes the reflect vector face the model (under horizon).
  54750. */
  54751. protected _useHorizonOcclusion: boolean;
  54752. /**
  54753. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54754. * too much the area relying on ambient texture to define their ambient occlusion.
  54755. */
  54756. protected _useRadianceOcclusion: boolean;
  54757. /**
  54758. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  54759. */
  54760. protected _useAlphaFromAlbedoTexture: boolean;
  54761. /**
  54762. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  54763. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  54764. */
  54765. protected _useSpecularOverAlpha: boolean;
  54766. /**
  54767. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  54768. */
  54769. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  54770. /**
  54771. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  54772. */
  54773. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  54774. /**
  54775. * Specifies if the metallic texture contains the roughness information in its green channel.
  54776. */
  54777. protected _useRoughnessFromMetallicTextureGreen: boolean;
  54778. /**
  54779. * Specifies if the metallic texture contains the metallness information in its blue channel.
  54780. */
  54781. protected _useMetallnessFromMetallicTextureBlue: boolean;
  54782. /**
  54783. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  54784. */
  54785. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  54786. /**
  54787. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  54788. */
  54789. protected _useAmbientInGrayScale: boolean;
  54790. /**
  54791. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  54792. * The material will try to infer what glossiness each pixel should be.
  54793. */
  54794. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  54795. /**
  54796. * Defines the falloff type used in this material.
  54797. * It by default is Physical.
  54798. */
  54799. protected _lightFalloff: number;
  54800. /**
  54801. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54802. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54803. */
  54804. protected _useRadianceOverAlpha: boolean;
  54805. /**
  54806. * Allows using an object space normal map (instead of tangent space).
  54807. */
  54808. protected _useObjectSpaceNormalMap: boolean;
  54809. /**
  54810. * Allows using the bump map in parallax mode.
  54811. */
  54812. protected _useParallax: boolean;
  54813. /**
  54814. * Allows using the bump map in parallax occlusion mode.
  54815. */
  54816. protected _useParallaxOcclusion: boolean;
  54817. /**
  54818. * Controls the scale bias of the parallax mode.
  54819. */
  54820. protected _parallaxScaleBias: number;
  54821. /**
  54822. * If sets to true, disables all the lights affecting the material.
  54823. */
  54824. protected _disableLighting: boolean;
  54825. /**
  54826. * Number of Simultaneous lights allowed on the material.
  54827. */
  54828. protected _maxSimultaneousLights: number;
  54829. /**
  54830. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  54831. */
  54832. protected _invertNormalMapX: boolean;
  54833. /**
  54834. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  54835. */
  54836. protected _invertNormalMapY: boolean;
  54837. /**
  54838. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54839. */
  54840. protected _twoSidedLighting: boolean;
  54841. /**
  54842. * Defines the alpha limits in alpha test mode.
  54843. */
  54844. protected _alphaCutOff: number;
  54845. /**
  54846. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54847. */
  54848. protected _forceAlphaTest: boolean;
  54849. /**
  54850. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54851. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54852. */
  54853. protected _useAlphaFresnel: boolean;
  54854. /**
  54855. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54856. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54857. */
  54858. protected _useLinearAlphaFresnel: boolean;
  54859. /**
  54860. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  54861. * from cos thetav and roughness:
  54862. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  54863. */
  54864. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  54865. /**
  54866. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54867. */
  54868. protected _forceIrradianceInFragment: boolean;
  54869. /**
  54870. * Force normal to face away from face.
  54871. */
  54872. protected _forceNormalForward: boolean;
  54873. /**
  54874. * Enables specular anti aliasing in the PBR shader.
  54875. * It will both interacts on the Geometry for analytical and IBL lighting.
  54876. * It also prefilter the roughness map based on the bump values.
  54877. */
  54878. protected _enableSpecularAntiAliasing: boolean;
  54879. /**
  54880. * Default configuration related to image processing available in the PBR Material.
  54881. */
  54882. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54883. /**
  54884. * Keep track of the image processing observer to allow dispose and replace.
  54885. */
  54886. private _imageProcessingObserver;
  54887. /**
  54888. * Attaches a new image processing configuration to the PBR Material.
  54889. * @param configuration
  54890. */
  54891. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54892. /**
  54893. * Stores the available render targets.
  54894. */
  54895. private _renderTargets;
  54896. /**
  54897. * Sets the global ambient color for the material used in lighting calculations.
  54898. */
  54899. private _globalAmbientColor;
  54900. /**
  54901. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  54902. */
  54903. private _useLogarithmicDepth;
  54904. /**
  54905. * If set to true, no lighting calculations will be applied.
  54906. */
  54907. private _unlit;
  54908. private _debugMode;
  54909. /**
  54910. * @hidden
  54911. * This is reserved for the inspector.
  54912. * Defines the material debug mode.
  54913. * It helps seeing only some components of the material while troubleshooting.
  54914. */
  54915. debugMode: number;
  54916. /**
  54917. * @hidden
  54918. * This is reserved for the inspector.
  54919. * Specify from where on screen the debug mode should start.
  54920. * The value goes from -1 (full screen) to 1 (not visible)
  54921. * It helps with side by side comparison against the final render
  54922. * This defaults to -1
  54923. */
  54924. private debugLimit;
  54925. /**
  54926. * @hidden
  54927. * This is reserved for the inspector.
  54928. * As the default viewing range might not be enough (if the ambient is really small for instance)
  54929. * You can use the factor to better multiply the final value.
  54930. */
  54931. private debugFactor;
  54932. /**
  54933. * Defines the clear coat layer parameters for the material.
  54934. */
  54935. readonly clearCoat: PBRClearCoatConfiguration;
  54936. /**
  54937. * Defines the anisotropic parameters for the material.
  54938. */
  54939. readonly anisotropy: PBRAnisotropicConfiguration;
  54940. /**
  54941. * Defines the BRDF parameters for the material.
  54942. */
  54943. readonly brdf: PBRBRDFConfiguration;
  54944. /**
  54945. * Defines the Sheen parameters for the material.
  54946. */
  54947. readonly sheen: PBRSheenConfiguration;
  54948. /**
  54949. * Defines the SubSurface parameters for the material.
  54950. */
  54951. readonly subSurface: PBRSubSurfaceConfiguration;
  54952. protected _rebuildInParallel: boolean;
  54953. /**
  54954. * Instantiates a new PBRMaterial instance.
  54955. *
  54956. * @param name The material name
  54957. * @param scene The scene the material will be use in.
  54958. */
  54959. constructor(name: string, scene: Scene);
  54960. /**
  54961. * Gets a boolean indicating that current material needs to register RTT
  54962. */
  54963. get hasRenderTargetTextures(): boolean;
  54964. /**
  54965. * Gets the name of the material class.
  54966. */
  54967. getClassName(): string;
  54968. /**
  54969. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  54970. */
  54971. get useLogarithmicDepth(): boolean;
  54972. /**
  54973. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  54974. */
  54975. set useLogarithmicDepth(value: boolean);
  54976. /**
  54977. * Returns true if alpha blending should be disabled.
  54978. */
  54979. protected get _disableAlphaBlending(): boolean;
  54980. /**
  54981. * Specifies whether or not this material should be rendered in alpha blend mode.
  54982. */
  54983. needAlphaBlending(): boolean;
  54984. /**
  54985. * Specifies whether or not this material should be rendered in alpha test mode.
  54986. */
  54987. needAlphaTesting(): boolean;
  54988. /**
  54989. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  54990. */
  54991. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  54992. /**
  54993. * Gets the texture used for the alpha test.
  54994. */
  54995. getAlphaTestTexture(): Nullable<BaseTexture>;
  54996. /**
  54997. * Specifies that the submesh is ready to be used.
  54998. * @param mesh - BJS mesh.
  54999. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  55000. * @param useInstances - Specifies that instances should be used.
  55001. * @returns - boolean indicating that the submesh is ready or not.
  55002. */
  55003. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55004. /**
  55005. * Specifies if the material uses metallic roughness workflow.
  55006. * @returns boolean specifiying if the material uses metallic roughness workflow.
  55007. */
  55008. isMetallicWorkflow(): boolean;
  55009. private _prepareEffect;
  55010. private _prepareDefines;
  55011. /**
  55012. * Force shader compilation
  55013. */
  55014. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  55015. /**
  55016. * Initializes the uniform buffer layout for the shader.
  55017. */
  55018. buildUniformLayout(): void;
  55019. /**
  55020. * Unbinds the material from the mesh
  55021. */
  55022. unbind(): void;
  55023. /**
  55024. * Binds the submesh data.
  55025. * @param world - The world matrix.
  55026. * @param mesh - The BJS mesh.
  55027. * @param subMesh - A submesh of the BJS mesh.
  55028. */
  55029. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55030. /**
  55031. * Returns the animatable textures.
  55032. * @returns - Array of animatable textures.
  55033. */
  55034. getAnimatables(): IAnimatable[];
  55035. /**
  55036. * Returns the texture used for reflections.
  55037. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  55038. */
  55039. private _getReflectionTexture;
  55040. /**
  55041. * Returns an array of the actively used textures.
  55042. * @returns - Array of BaseTextures
  55043. */
  55044. getActiveTextures(): BaseTexture[];
  55045. /**
  55046. * Checks to see if a texture is used in the material.
  55047. * @param texture - Base texture to use.
  55048. * @returns - Boolean specifying if a texture is used in the material.
  55049. */
  55050. hasTexture(texture: BaseTexture): boolean;
  55051. /**
  55052. * Disposes the resources of the material.
  55053. * @param forceDisposeEffect - Forces the disposal of effects.
  55054. * @param forceDisposeTextures - Forces the disposal of all textures.
  55055. */
  55056. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  55057. }
  55058. }
  55059. declare module BABYLON {
  55060. /**
  55061. * The Physically based material of BJS.
  55062. *
  55063. * This offers the main features of a standard PBR material.
  55064. * For more information, please refer to the documentation :
  55065. * https://doc.babylonjs.com/how_to/physically_based_rendering
  55066. */
  55067. export class PBRMaterial extends PBRBaseMaterial {
  55068. /**
  55069. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  55070. */
  55071. static readonly PBRMATERIAL_OPAQUE: number;
  55072. /**
  55073. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  55074. */
  55075. static readonly PBRMATERIAL_ALPHATEST: number;
  55076. /**
  55077. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55078. */
  55079. static readonly PBRMATERIAL_ALPHABLEND: number;
  55080. /**
  55081. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55082. * They are also discarded below the alpha cutoff threshold to improve performances.
  55083. */
  55084. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  55085. /**
  55086. * Defines the default value of how much AO map is occluding the analytical lights
  55087. * (point spot...).
  55088. */
  55089. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  55090. /**
  55091. * Intensity of the direct lights e.g. the four lights available in your scene.
  55092. * This impacts both the direct diffuse and specular highlights.
  55093. */
  55094. directIntensity: number;
  55095. /**
  55096. * Intensity of the emissive part of the material.
  55097. * This helps controlling the emissive effect without modifying the emissive color.
  55098. */
  55099. emissiveIntensity: number;
  55100. /**
  55101. * Intensity of the environment e.g. how much the environment will light the object
  55102. * either through harmonics for rough material or through the refelction for shiny ones.
  55103. */
  55104. environmentIntensity: number;
  55105. /**
  55106. * This is a special control allowing the reduction of the specular highlights coming from the
  55107. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  55108. */
  55109. specularIntensity: number;
  55110. /**
  55111. * Debug Control allowing disabling the bump map on this material.
  55112. */
  55113. disableBumpMap: boolean;
  55114. /**
  55115. * AKA Diffuse Texture in standard nomenclature.
  55116. */
  55117. albedoTexture: BaseTexture;
  55118. /**
  55119. * AKA Occlusion Texture in other nomenclature.
  55120. */
  55121. ambientTexture: BaseTexture;
  55122. /**
  55123. * AKA Occlusion Texture Intensity in other nomenclature.
  55124. */
  55125. ambientTextureStrength: number;
  55126. /**
  55127. * Defines how much the AO map is occluding the analytical lights (point spot...).
  55128. * 1 means it completely occludes it
  55129. * 0 mean it has no impact
  55130. */
  55131. ambientTextureImpactOnAnalyticalLights: number;
  55132. /**
  55133. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  55134. */
  55135. opacityTexture: BaseTexture;
  55136. /**
  55137. * Stores the reflection values in a texture.
  55138. */
  55139. reflectionTexture: Nullable<BaseTexture>;
  55140. /**
  55141. * Stores the emissive values in a texture.
  55142. */
  55143. emissiveTexture: BaseTexture;
  55144. /**
  55145. * AKA Specular texture in other nomenclature.
  55146. */
  55147. reflectivityTexture: BaseTexture;
  55148. /**
  55149. * Used to switch from specular/glossiness to metallic/roughness workflow.
  55150. */
  55151. metallicTexture: BaseTexture;
  55152. /**
  55153. * Specifies the metallic scalar of the metallic/roughness workflow.
  55154. * Can also be used to scale the metalness values of the metallic texture.
  55155. */
  55156. metallic: Nullable<number>;
  55157. /**
  55158. * Specifies the roughness scalar of the metallic/roughness workflow.
  55159. * Can also be used to scale the roughness values of the metallic texture.
  55160. */
  55161. roughness: Nullable<number>;
  55162. /**
  55163. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  55164. * By default the indexOfrefraction is used to compute F0;
  55165. *
  55166. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  55167. *
  55168. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  55169. * F90 = metallicReflectanceColor;
  55170. */
  55171. metallicF0Factor: number;
  55172. /**
  55173. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  55174. * By default the F90 is always 1;
  55175. *
  55176. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  55177. *
  55178. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  55179. * F90 = metallicReflectanceColor;
  55180. */
  55181. metallicReflectanceColor: Color3;
  55182. /**
  55183. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  55184. * This is multiply against the scalar values defined in the material.
  55185. */
  55186. metallicReflectanceTexture: Nullable<BaseTexture>;
  55187. /**
  55188. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  55189. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  55190. */
  55191. microSurfaceTexture: BaseTexture;
  55192. /**
  55193. * Stores surface normal data used to displace a mesh in a texture.
  55194. */
  55195. bumpTexture: BaseTexture;
  55196. /**
  55197. * Stores the pre-calculated light information of a mesh in a texture.
  55198. */
  55199. lightmapTexture: BaseTexture;
  55200. /**
  55201. * Stores the refracted light information in a texture.
  55202. */
  55203. get refractionTexture(): Nullable<BaseTexture>;
  55204. set refractionTexture(value: Nullable<BaseTexture>);
  55205. /**
  55206. * The color of a material in ambient lighting.
  55207. */
  55208. ambientColor: Color3;
  55209. /**
  55210. * AKA Diffuse Color in other nomenclature.
  55211. */
  55212. albedoColor: Color3;
  55213. /**
  55214. * AKA Specular Color in other nomenclature.
  55215. */
  55216. reflectivityColor: Color3;
  55217. /**
  55218. * The color reflected from the material.
  55219. */
  55220. reflectionColor: Color3;
  55221. /**
  55222. * The color emitted from the material.
  55223. */
  55224. emissiveColor: Color3;
  55225. /**
  55226. * AKA Glossiness in other nomenclature.
  55227. */
  55228. microSurface: number;
  55229. /**
  55230. * Index of refraction of the material base layer.
  55231. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55232. *
  55233. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  55234. *
  55235. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  55236. */
  55237. get indexOfRefraction(): number;
  55238. set indexOfRefraction(value: number);
  55239. /**
  55240. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  55241. */
  55242. get invertRefractionY(): boolean;
  55243. set invertRefractionY(value: boolean);
  55244. /**
  55245. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  55246. * Materials half opaque for instance using refraction could benefit from this control.
  55247. */
  55248. get linkRefractionWithTransparency(): boolean;
  55249. set linkRefractionWithTransparency(value: boolean);
  55250. /**
  55251. * If true, the light map contains occlusion information instead of lighting info.
  55252. */
  55253. useLightmapAsShadowmap: boolean;
  55254. /**
  55255. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  55256. */
  55257. useAlphaFromAlbedoTexture: boolean;
  55258. /**
  55259. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  55260. */
  55261. forceAlphaTest: boolean;
  55262. /**
  55263. * Defines the alpha limits in alpha test mode.
  55264. */
  55265. alphaCutOff: number;
  55266. /**
  55267. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  55268. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  55269. */
  55270. useSpecularOverAlpha: boolean;
  55271. /**
  55272. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  55273. */
  55274. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  55275. /**
  55276. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  55277. */
  55278. useRoughnessFromMetallicTextureAlpha: boolean;
  55279. /**
  55280. * Specifies if the metallic texture contains the roughness information in its green channel.
  55281. */
  55282. useRoughnessFromMetallicTextureGreen: boolean;
  55283. /**
  55284. * Specifies if the metallic texture contains the metallness information in its blue channel.
  55285. */
  55286. useMetallnessFromMetallicTextureBlue: boolean;
  55287. /**
  55288. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  55289. */
  55290. useAmbientOcclusionFromMetallicTextureRed: boolean;
  55291. /**
  55292. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  55293. */
  55294. useAmbientInGrayScale: boolean;
  55295. /**
  55296. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  55297. * The material will try to infer what glossiness each pixel should be.
  55298. */
  55299. useAutoMicroSurfaceFromReflectivityMap: boolean;
  55300. /**
  55301. * BJS is using an harcoded light falloff based on a manually sets up range.
  55302. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  55303. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  55304. */
  55305. get usePhysicalLightFalloff(): boolean;
  55306. /**
  55307. * BJS is using an harcoded light falloff based on a manually sets up range.
  55308. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  55309. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  55310. */
  55311. set usePhysicalLightFalloff(value: boolean);
  55312. /**
  55313. * In order to support the falloff compatibility with gltf, a special mode has been added
  55314. * to reproduce the gltf light falloff.
  55315. */
  55316. get useGLTFLightFalloff(): boolean;
  55317. /**
  55318. * In order to support the falloff compatibility with gltf, a special mode has been added
  55319. * to reproduce the gltf light falloff.
  55320. */
  55321. set useGLTFLightFalloff(value: boolean);
  55322. /**
  55323. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  55324. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  55325. */
  55326. useRadianceOverAlpha: boolean;
  55327. /**
  55328. * Allows using an object space normal map (instead of tangent space).
  55329. */
  55330. useObjectSpaceNormalMap: boolean;
  55331. /**
  55332. * Allows using the bump map in parallax mode.
  55333. */
  55334. useParallax: boolean;
  55335. /**
  55336. * Allows using the bump map in parallax occlusion mode.
  55337. */
  55338. useParallaxOcclusion: boolean;
  55339. /**
  55340. * Controls the scale bias of the parallax mode.
  55341. */
  55342. parallaxScaleBias: number;
  55343. /**
  55344. * If sets to true, disables all the lights affecting the material.
  55345. */
  55346. disableLighting: boolean;
  55347. /**
  55348. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  55349. */
  55350. forceIrradianceInFragment: boolean;
  55351. /**
  55352. * Number of Simultaneous lights allowed on the material.
  55353. */
  55354. maxSimultaneousLights: number;
  55355. /**
  55356. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55357. */
  55358. invertNormalMapX: boolean;
  55359. /**
  55360. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55361. */
  55362. invertNormalMapY: boolean;
  55363. /**
  55364. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55365. */
  55366. twoSidedLighting: boolean;
  55367. /**
  55368. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55369. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  55370. */
  55371. useAlphaFresnel: boolean;
  55372. /**
  55373. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55374. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  55375. */
  55376. useLinearAlphaFresnel: boolean;
  55377. /**
  55378. * Let user defines the brdf lookup texture used for IBL.
  55379. * A default 8bit version is embedded but you could point at :
  55380. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  55381. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  55382. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  55383. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  55384. */
  55385. environmentBRDFTexture: Nullable<BaseTexture>;
  55386. /**
  55387. * Force normal to face away from face.
  55388. */
  55389. forceNormalForward: boolean;
  55390. /**
  55391. * Enables specular anti aliasing in the PBR shader.
  55392. * It will both interacts on the Geometry for analytical and IBL lighting.
  55393. * It also prefilter the roughness map based on the bump values.
  55394. */
  55395. enableSpecularAntiAliasing: boolean;
  55396. /**
  55397. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  55398. * makes the reflect vector face the model (under horizon).
  55399. */
  55400. useHorizonOcclusion: boolean;
  55401. /**
  55402. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  55403. * too much the area relying on ambient texture to define their ambient occlusion.
  55404. */
  55405. useRadianceOcclusion: boolean;
  55406. /**
  55407. * If set to true, no lighting calculations will be applied.
  55408. */
  55409. unlit: boolean;
  55410. /**
  55411. * Gets the image processing configuration used either in this material.
  55412. */
  55413. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  55414. /**
  55415. * Sets the Default image processing configuration used either in the this material.
  55416. *
  55417. * If sets to null, the scene one is in use.
  55418. */
  55419. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  55420. /**
  55421. * Gets wether the color curves effect is enabled.
  55422. */
  55423. get cameraColorCurvesEnabled(): boolean;
  55424. /**
  55425. * Sets wether the color curves effect is enabled.
  55426. */
  55427. set cameraColorCurvesEnabled(value: boolean);
  55428. /**
  55429. * Gets wether the color grading effect is enabled.
  55430. */
  55431. get cameraColorGradingEnabled(): boolean;
  55432. /**
  55433. * Gets wether the color grading effect is enabled.
  55434. */
  55435. set cameraColorGradingEnabled(value: boolean);
  55436. /**
  55437. * Gets wether tonemapping is enabled or not.
  55438. */
  55439. get cameraToneMappingEnabled(): boolean;
  55440. /**
  55441. * Sets wether tonemapping is enabled or not
  55442. */
  55443. set cameraToneMappingEnabled(value: boolean);
  55444. /**
  55445. * The camera exposure used on this material.
  55446. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55447. * This corresponds to a photographic exposure.
  55448. */
  55449. get cameraExposure(): number;
  55450. /**
  55451. * The camera exposure used on this material.
  55452. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55453. * This corresponds to a photographic exposure.
  55454. */
  55455. set cameraExposure(value: number);
  55456. /**
  55457. * Gets The camera contrast used on this material.
  55458. */
  55459. get cameraContrast(): number;
  55460. /**
  55461. * Sets The camera contrast used on this material.
  55462. */
  55463. set cameraContrast(value: number);
  55464. /**
  55465. * Gets the Color Grading 2D Lookup Texture.
  55466. */
  55467. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  55468. /**
  55469. * Sets the Color Grading 2D Lookup Texture.
  55470. */
  55471. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  55472. /**
  55473. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55474. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55475. * 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;
  55476. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55477. */
  55478. get cameraColorCurves(): Nullable<ColorCurves>;
  55479. /**
  55480. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55481. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55482. * 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;
  55483. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55484. */
  55485. set cameraColorCurves(value: Nullable<ColorCurves>);
  55486. /**
  55487. * Instantiates a new PBRMaterial instance.
  55488. *
  55489. * @param name The material name
  55490. * @param scene The scene the material will be use in.
  55491. */
  55492. constructor(name: string, scene: Scene);
  55493. /**
  55494. * Returns the name of this material class.
  55495. */
  55496. getClassName(): string;
  55497. /**
  55498. * Makes a duplicate of the current material.
  55499. * @param name - name to use for the new material.
  55500. */
  55501. clone(name: string): PBRMaterial;
  55502. /**
  55503. * Serializes this PBR Material.
  55504. * @returns - An object with the serialized material.
  55505. */
  55506. serialize(): any;
  55507. /**
  55508. * Parses a PBR Material from a serialized object.
  55509. * @param source - Serialized object.
  55510. * @param scene - BJS scene instance.
  55511. * @param rootUrl - url for the scene object
  55512. * @returns - PBRMaterial
  55513. */
  55514. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  55515. }
  55516. }
  55517. declare module BABYLON {
  55518. /**
  55519. * Direct draw surface info
  55520. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  55521. */
  55522. export interface DDSInfo {
  55523. /**
  55524. * Width of the texture
  55525. */
  55526. width: number;
  55527. /**
  55528. * Width of the texture
  55529. */
  55530. height: number;
  55531. /**
  55532. * Number of Mipmaps for the texture
  55533. * @see https://en.wikipedia.org/wiki/Mipmap
  55534. */
  55535. mipmapCount: number;
  55536. /**
  55537. * If the textures format is a known fourCC format
  55538. * @see https://www.fourcc.org/
  55539. */
  55540. isFourCC: boolean;
  55541. /**
  55542. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  55543. */
  55544. isRGB: boolean;
  55545. /**
  55546. * If the texture is a lumincance format
  55547. */
  55548. isLuminance: boolean;
  55549. /**
  55550. * If this is a cube texture
  55551. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  55552. */
  55553. isCube: boolean;
  55554. /**
  55555. * If the texture is a compressed format eg. FOURCC_DXT1
  55556. */
  55557. isCompressed: boolean;
  55558. /**
  55559. * The dxgiFormat of the texture
  55560. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  55561. */
  55562. dxgiFormat: number;
  55563. /**
  55564. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  55565. */
  55566. textureType: number;
  55567. /**
  55568. * Sphericle polynomial created for the dds texture
  55569. */
  55570. sphericalPolynomial?: SphericalPolynomial;
  55571. }
  55572. /**
  55573. * Class used to provide DDS decompression tools
  55574. */
  55575. export class DDSTools {
  55576. /**
  55577. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  55578. */
  55579. static StoreLODInAlphaChannel: boolean;
  55580. /**
  55581. * Gets DDS information from an array buffer
  55582. * @param data defines the array buffer view to read data from
  55583. * @returns the DDS information
  55584. */
  55585. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  55586. private static _FloatView;
  55587. private static _Int32View;
  55588. private static _ToHalfFloat;
  55589. private static _FromHalfFloat;
  55590. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  55591. private static _GetHalfFloatRGBAArrayBuffer;
  55592. private static _GetFloatRGBAArrayBuffer;
  55593. private static _GetFloatAsUIntRGBAArrayBuffer;
  55594. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  55595. private static _GetRGBAArrayBuffer;
  55596. private static _ExtractLongWordOrder;
  55597. private static _GetRGBArrayBuffer;
  55598. private static _GetLuminanceArrayBuffer;
  55599. /**
  55600. * Uploads DDS Levels to a Babylon Texture
  55601. * @hidden
  55602. */
  55603. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  55604. }
  55605. interface ThinEngine {
  55606. /**
  55607. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  55608. * @param rootUrl defines the url where the file to load is located
  55609. * @param scene defines the current scene
  55610. * @param lodScale defines scale to apply to the mip map selection
  55611. * @param lodOffset defines offset to apply to the mip map selection
  55612. * @param onLoad defines an optional callback raised when the texture is loaded
  55613. * @param onError defines an optional callback raised if there is an issue to load the texture
  55614. * @param format defines the format of the data
  55615. * @param forcedExtension defines the extension to use to pick the right loader
  55616. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  55617. * @returns the cube texture as an InternalTexture
  55618. */
  55619. 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;
  55620. }
  55621. }
  55622. declare module BABYLON {
  55623. /**
  55624. * Implementation of the DDS Texture Loader.
  55625. * @hidden
  55626. */
  55627. export class _DDSTextureLoader implements IInternalTextureLoader {
  55628. /**
  55629. * Defines wether the loader supports cascade loading the different faces.
  55630. */
  55631. readonly supportCascades: boolean;
  55632. /**
  55633. * This returns if the loader support the current file information.
  55634. * @param extension defines the file extension of the file being loaded
  55635. * @returns true if the loader can load the specified file
  55636. */
  55637. canLoad(extension: string): boolean;
  55638. /**
  55639. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55640. * @param data contains the texture data
  55641. * @param texture defines the BabylonJS internal texture
  55642. * @param createPolynomials will be true if polynomials have been requested
  55643. * @param onLoad defines the callback to trigger once the texture is ready
  55644. * @param onError defines the callback to trigger in case of error
  55645. */
  55646. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55647. /**
  55648. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55649. * @param data contains the texture data
  55650. * @param texture defines the BabylonJS internal texture
  55651. * @param callback defines the method to call once ready to upload
  55652. */
  55653. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55654. }
  55655. }
  55656. declare module BABYLON {
  55657. /**
  55658. * Implementation of the ENV Texture Loader.
  55659. * @hidden
  55660. */
  55661. export class _ENVTextureLoader implements IInternalTextureLoader {
  55662. /**
  55663. * Defines wether the loader supports cascade loading the different faces.
  55664. */
  55665. readonly supportCascades: boolean;
  55666. /**
  55667. * This returns if the loader support the current file information.
  55668. * @param extension defines the file extension of the file being loaded
  55669. * @returns true if the loader can load the specified file
  55670. */
  55671. canLoad(extension: string): boolean;
  55672. /**
  55673. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55674. * @param data contains the texture data
  55675. * @param texture defines the BabylonJS internal texture
  55676. * @param createPolynomials will be true if polynomials have been requested
  55677. * @param onLoad defines the callback to trigger once the texture is ready
  55678. * @param onError defines the callback to trigger in case of error
  55679. */
  55680. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55681. /**
  55682. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55683. * @param data contains the texture data
  55684. * @param texture defines the BabylonJS internal texture
  55685. * @param callback defines the method to call once ready to upload
  55686. */
  55687. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55688. }
  55689. }
  55690. declare module BABYLON {
  55691. /**
  55692. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  55693. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  55694. */
  55695. export class KhronosTextureContainer {
  55696. /** contents of the KTX container file */
  55697. data: ArrayBufferView;
  55698. private static HEADER_LEN;
  55699. private static COMPRESSED_2D;
  55700. private static COMPRESSED_3D;
  55701. private static TEX_2D;
  55702. private static TEX_3D;
  55703. /**
  55704. * Gets the openGL type
  55705. */
  55706. glType: number;
  55707. /**
  55708. * Gets the openGL type size
  55709. */
  55710. glTypeSize: number;
  55711. /**
  55712. * Gets the openGL format
  55713. */
  55714. glFormat: number;
  55715. /**
  55716. * Gets the openGL internal format
  55717. */
  55718. glInternalFormat: number;
  55719. /**
  55720. * Gets the base internal format
  55721. */
  55722. glBaseInternalFormat: number;
  55723. /**
  55724. * Gets image width in pixel
  55725. */
  55726. pixelWidth: number;
  55727. /**
  55728. * Gets image height in pixel
  55729. */
  55730. pixelHeight: number;
  55731. /**
  55732. * Gets image depth in pixels
  55733. */
  55734. pixelDepth: number;
  55735. /**
  55736. * Gets the number of array elements
  55737. */
  55738. numberOfArrayElements: number;
  55739. /**
  55740. * Gets the number of faces
  55741. */
  55742. numberOfFaces: number;
  55743. /**
  55744. * Gets the number of mipmap levels
  55745. */
  55746. numberOfMipmapLevels: number;
  55747. /**
  55748. * Gets the bytes of key value data
  55749. */
  55750. bytesOfKeyValueData: number;
  55751. /**
  55752. * Gets the load type
  55753. */
  55754. loadType: number;
  55755. /**
  55756. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  55757. */
  55758. isInvalid: boolean;
  55759. /**
  55760. * Creates a new KhronosTextureContainer
  55761. * @param data contents of the KTX container file
  55762. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  55763. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  55764. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  55765. */
  55766. constructor(
  55767. /** contents of the KTX container file */
  55768. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  55769. /**
  55770. * Uploads KTX content to a Babylon Texture.
  55771. * It is assumed that the texture has already been created & is currently bound
  55772. * @hidden
  55773. */
  55774. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  55775. private _upload2DCompressedLevels;
  55776. /**
  55777. * Checks if the given data starts with a KTX file identifier.
  55778. * @param data the data to check
  55779. * @returns true if the data is a KTX file or false otherwise
  55780. */
  55781. static IsValid(data: ArrayBufferView): boolean;
  55782. }
  55783. }
  55784. declare module BABYLON {
  55785. /**
  55786. * Class for loading KTX2 files
  55787. * !!! Experimental Extension Subject to Changes !!!
  55788. * @hidden
  55789. */
  55790. export class KhronosTextureContainer2 {
  55791. private static _ModulePromise;
  55792. private static _TranscodeFormat;
  55793. constructor(engine: ThinEngine);
  55794. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  55795. private _determineTranscodeFormat;
  55796. /**
  55797. * Checks if the given data starts with a KTX2 file identifier.
  55798. * @param data the data to check
  55799. * @returns true if the data is a KTX2 file or false otherwise
  55800. */
  55801. static IsValid(data: ArrayBufferView): boolean;
  55802. }
  55803. }
  55804. declare module BABYLON {
  55805. /**
  55806. * Implementation of the KTX Texture Loader.
  55807. * @hidden
  55808. */
  55809. export class _KTXTextureLoader implements IInternalTextureLoader {
  55810. /**
  55811. * Defines wether the loader supports cascade loading the different faces.
  55812. */
  55813. readonly supportCascades: boolean;
  55814. /**
  55815. * This returns if the loader support the current file information.
  55816. * @param extension defines the file extension of the file being loaded
  55817. * @returns true if the loader can load the specified file
  55818. */
  55819. canLoad(extension: string): boolean;
  55820. /**
  55821. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55822. * @param data contains the texture data
  55823. * @param texture defines the BabylonJS internal texture
  55824. * @param createPolynomials will be true if polynomials have been requested
  55825. * @param onLoad defines the callback to trigger once the texture is ready
  55826. * @param onError defines the callback to trigger in case of error
  55827. */
  55828. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55829. /**
  55830. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55831. * @param data contains the texture data
  55832. * @param texture defines the BabylonJS internal texture
  55833. * @param callback defines the method to call once ready to upload
  55834. */
  55835. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  55836. }
  55837. }
  55838. declare module BABYLON {
  55839. /** @hidden */
  55840. export var _forceSceneHelpersToBundle: boolean;
  55841. interface Scene {
  55842. /**
  55843. * Creates a default light for the scene.
  55844. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  55845. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  55846. */
  55847. createDefaultLight(replace?: boolean): void;
  55848. /**
  55849. * Creates a default camera for the scene.
  55850. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  55851. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  55852. * @param replace has default false, when true replaces the active camera in the scene
  55853. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  55854. */
  55855. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  55856. /**
  55857. * Creates a default camera and a default light.
  55858. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  55859. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  55860. * @param replace has the default false, when true replaces the active camera/light in the scene
  55861. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  55862. */
  55863. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  55864. /**
  55865. * Creates a new sky box
  55866. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  55867. * @param environmentTexture defines the texture to use as environment texture
  55868. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  55869. * @param scale defines the overall scale of the skybox
  55870. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  55871. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  55872. * @returns a new mesh holding the sky box
  55873. */
  55874. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  55875. /**
  55876. * Creates a new environment
  55877. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  55878. * @param options defines the options you can use to configure the environment
  55879. * @returns the new EnvironmentHelper
  55880. */
  55881. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  55882. /**
  55883. * Creates a new VREXperienceHelper
  55884. * @see http://doc.babylonjs.com/how_to/webvr_helper
  55885. * @param webVROptions defines the options used to create the new VREXperienceHelper
  55886. * @returns a new VREXperienceHelper
  55887. */
  55888. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  55889. /**
  55890. * Creates a new WebXRDefaultExperience
  55891. * @see http://doc.babylonjs.com/how_to/webxr
  55892. * @param options experience options
  55893. * @returns a promise for a new WebXRDefaultExperience
  55894. */
  55895. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  55896. }
  55897. }
  55898. declare module BABYLON {
  55899. /**
  55900. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  55901. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  55902. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  55903. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55904. */
  55905. export class VideoDome extends TransformNode {
  55906. /**
  55907. * Define the video source as a Monoscopic panoramic 360 video.
  55908. */
  55909. static readonly MODE_MONOSCOPIC: number;
  55910. /**
  55911. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  55912. */
  55913. static readonly MODE_TOPBOTTOM: number;
  55914. /**
  55915. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  55916. */
  55917. static readonly MODE_SIDEBYSIDE: number;
  55918. private _halfDome;
  55919. private _useDirectMapping;
  55920. /**
  55921. * The video texture being displayed on the sphere
  55922. */
  55923. protected _videoTexture: VideoTexture;
  55924. /**
  55925. * Gets the video texture being displayed on the sphere
  55926. */
  55927. get videoTexture(): VideoTexture;
  55928. /**
  55929. * The skybox material
  55930. */
  55931. protected _material: BackgroundMaterial;
  55932. /**
  55933. * The surface used for the skybox
  55934. */
  55935. protected _mesh: Mesh;
  55936. /**
  55937. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  55938. */
  55939. private _halfDomeMask;
  55940. /**
  55941. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55942. * Also see the options.resolution property.
  55943. */
  55944. get fovMultiplier(): number;
  55945. set fovMultiplier(value: number);
  55946. private _videoMode;
  55947. /**
  55948. * Gets or set the current video mode for the video. It can be:
  55949. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  55950. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  55951. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  55952. */
  55953. get videoMode(): number;
  55954. set videoMode(value: number);
  55955. /**
  55956. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  55957. *
  55958. */
  55959. get halfDome(): boolean;
  55960. /**
  55961. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  55962. */
  55963. set halfDome(enabled: boolean);
  55964. /**
  55965. * Oberserver used in Stereoscopic VR Mode.
  55966. */
  55967. private _onBeforeCameraRenderObserver;
  55968. /**
  55969. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  55970. * @param name Element's name, child elements will append suffixes for their own names.
  55971. * @param urlsOrVideo defines the url(s) or the video element to use
  55972. * @param options An object containing optional or exposed sub element properties
  55973. */
  55974. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  55975. resolution?: number;
  55976. clickToPlay?: boolean;
  55977. autoPlay?: boolean;
  55978. loop?: boolean;
  55979. size?: number;
  55980. poster?: string;
  55981. faceForward?: boolean;
  55982. useDirectMapping?: boolean;
  55983. halfDomeMode?: boolean;
  55984. }, scene: Scene);
  55985. private _changeVideoMode;
  55986. /**
  55987. * Releases resources associated with this node.
  55988. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  55989. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  55990. */
  55991. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  55992. }
  55993. }
  55994. declare module BABYLON {
  55995. /**
  55996. * This class can be used to get instrumentation data from a Babylon engine
  55997. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  55998. */
  55999. export class EngineInstrumentation implements IDisposable {
  56000. /**
  56001. * Define the instrumented engine.
  56002. */
  56003. engine: Engine;
  56004. private _captureGPUFrameTime;
  56005. private _gpuFrameTimeToken;
  56006. private _gpuFrameTime;
  56007. private _captureShaderCompilationTime;
  56008. private _shaderCompilationTime;
  56009. private _onBeginFrameObserver;
  56010. private _onEndFrameObserver;
  56011. private _onBeforeShaderCompilationObserver;
  56012. private _onAfterShaderCompilationObserver;
  56013. /**
  56014. * Gets the perf counter used for GPU frame time
  56015. */
  56016. get gpuFrameTimeCounter(): PerfCounter;
  56017. /**
  56018. * Gets the GPU frame time capture status
  56019. */
  56020. get captureGPUFrameTime(): boolean;
  56021. /**
  56022. * Enable or disable the GPU frame time capture
  56023. */
  56024. set captureGPUFrameTime(value: boolean);
  56025. /**
  56026. * Gets the perf counter used for shader compilation time
  56027. */
  56028. get shaderCompilationTimeCounter(): PerfCounter;
  56029. /**
  56030. * Gets the shader compilation time capture status
  56031. */
  56032. get captureShaderCompilationTime(): boolean;
  56033. /**
  56034. * Enable or disable the shader compilation time capture
  56035. */
  56036. set captureShaderCompilationTime(value: boolean);
  56037. /**
  56038. * Instantiates a new engine instrumentation.
  56039. * This class can be used to get instrumentation data from a Babylon engine
  56040. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  56041. * @param engine Defines the engine to instrument
  56042. */
  56043. constructor(
  56044. /**
  56045. * Define the instrumented engine.
  56046. */
  56047. engine: Engine);
  56048. /**
  56049. * Dispose and release associated resources.
  56050. */
  56051. dispose(): void;
  56052. }
  56053. }
  56054. declare module BABYLON {
  56055. /**
  56056. * This class can be used to get instrumentation data from a Babylon engine
  56057. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56058. */
  56059. export class SceneInstrumentation implements IDisposable {
  56060. /**
  56061. * Defines the scene to instrument
  56062. */
  56063. scene: Scene;
  56064. private _captureActiveMeshesEvaluationTime;
  56065. private _activeMeshesEvaluationTime;
  56066. private _captureRenderTargetsRenderTime;
  56067. private _renderTargetsRenderTime;
  56068. private _captureFrameTime;
  56069. private _frameTime;
  56070. private _captureRenderTime;
  56071. private _renderTime;
  56072. private _captureInterFrameTime;
  56073. private _interFrameTime;
  56074. private _captureParticlesRenderTime;
  56075. private _particlesRenderTime;
  56076. private _captureSpritesRenderTime;
  56077. private _spritesRenderTime;
  56078. private _capturePhysicsTime;
  56079. private _physicsTime;
  56080. private _captureAnimationsTime;
  56081. private _animationsTime;
  56082. private _captureCameraRenderTime;
  56083. private _cameraRenderTime;
  56084. private _onBeforeActiveMeshesEvaluationObserver;
  56085. private _onAfterActiveMeshesEvaluationObserver;
  56086. private _onBeforeRenderTargetsRenderObserver;
  56087. private _onAfterRenderTargetsRenderObserver;
  56088. private _onAfterRenderObserver;
  56089. private _onBeforeDrawPhaseObserver;
  56090. private _onAfterDrawPhaseObserver;
  56091. private _onBeforeAnimationsObserver;
  56092. private _onBeforeParticlesRenderingObserver;
  56093. private _onAfterParticlesRenderingObserver;
  56094. private _onBeforeSpritesRenderingObserver;
  56095. private _onAfterSpritesRenderingObserver;
  56096. private _onBeforePhysicsObserver;
  56097. private _onAfterPhysicsObserver;
  56098. private _onAfterAnimationsObserver;
  56099. private _onBeforeCameraRenderObserver;
  56100. private _onAfterCameraRenderObserver;
  56101. /**
  56102. * Gets the perf counter used for active meshes evaluation time
  56103. */
  56104. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  56105. /**
  56106. * Gets the active meshes evaluation time capture status
  56107. */
  56108. get captureActiveMeshesEvaluationTime(): boolean;
  56109. /**
  56110. * Enable or disable the active meshes evaluation time capture
  56111. */
  56112. set captureActiveMeshesEvaluationTime(value: boolean);
  56113. /**
  56114. * Gets the perf counter used for render targets render time
  56115. */
  56116. get renderTargetsRenderTimeCounter(): PerfCounter;
  56117. /**
  56118. * Gets the render targets render time capture status
  56119. */
  56120. get captureRenderTargetsRenderTime(): boolean;
  56121. /**
  56122. * Enable or disable the render targets render time capture
  56123. */
  56124. set captureRenderTargetsRenderTime(value: boolean);
  56125. /**
  56126. * Gets the perf counter used for particles render time
  56127. */
  56128. get particlesRenderTimeCounter(): PerfCounter;
  56129. /**
  56130. * Gets the particles render time capture status
  56131. */
  56132. get captureParticlesRenderTime(): boolean;
  56133. /**
  56134. * Enable or disable the particles render time capture
  56135. */
  56136. set captureParticlesRenderTime(value: boolean);
  56137. /**
  56138. * Gets the perf counter used for sprites render time
  56139. */
  56140. get spritesRenderTimeCounter(): PerfCounter;
  56141. /**
  56142. * Gets the sprites render time capture status
  56143. */
  56144. get captureSpritesRenderTime(): boolean;
  56145. /**
  56146. * Enable or disable the sprites render time capture
  56147. */
  56148. set captureSpritesRenderTime(value: boolean);
  56149. /**
  56150. * Gets the perf counter used for physics time
  56151. */
  56152. get physicsTimeCounter(): PerfCounter;
  56153. /**
  56154. * Gets the physics time capture status
  56155. */
  56156. get capturePhysicsTime(): boolean;
  56157. /**
  56158. * Enable or disable the physics time capture
  56159. */
  56160. set capturePhysicsTime(value: boolean);
  56161. /**
  56162. * Gets the perf counter used for animations time
  56163. */
  56164. get animationsTimeCounter(): PerfCounter;
  56165. /**
  56166. * Gets the animations time capture status
  56167. */
  56168. get captureAnimationsTime(): boolean;
  56169. /**
  56170. * Enable or disable the animations time capture
  56171. */
  56172. set captureAnimationsTime(value: boolean);
  56173. /**
  56174. * Gets the perf counter used for frame time capture
  56175. */
  56176. get frameTimeCounter(): PerfCounter;
  56177. /**
  56178. * Gets the frame time capture status
  56179. */
  56180. get captureFrameTime(): boolean;
  56181. /**
  56182. * Enable or disable the frame time capture
  56183. */
  56184. set captureFrameTime(value: boolean);
  56185. /**
  56186. * Gets the perf counter used for inter-frames time capture
  56187. */
  56188. get interFrameTimeCounter(): PerfCounter;
  56189. /**
  56190. * Gets the inter-frames time capture status
  56191. */
  56192. get captureInterFrameTime(): boolean;
  56193. /**
  56194. * Enable or disable the inter-frames time capture
  56195. */
  56196. set captureInterFrameTime(value: boolean);
  56197. /**
  56198. * Gets the perf counter used for render time capture
  56199. */
  56200. get renderTimeCounter(): PerfCounter;
  56201. /**
  56202. * Gets the render time capture status
  56203. */
  56204. get captureRenderTime(): boolean;
  56205. /**
  56206. * Enable or disable the render time capture
  56207. */
  56208. set captureRenderTime(value: boolean);
  56209. /**
  56210. * Gets the perf counter used for camera render time capture
  56211. */
  56212. get cameraRenderTimeCounter(): PerfCounter;
  56213. /**
  56214. * Gets the camera render time capture status
  56215. */
  56216. get captureCameraRenderTime(): boolean;
  56217. /**
  56218. * Enable or disable the camera render time capture
  56219. */
  56220. set captureCameraRenderTime(value: boolean);
  56221. /**
  56222. * Gets the perf counter used for draw calls
  56223. */
  56224. get drawCallsCounter(): PerfCounter;
  56225. /**
  56226. * Instantiates a new scene instrumentation.
  56227. * This class can be used to get instrumentation data from a Babylon engine
  56228. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56229. * @param scene Defines the scene to instrument
  56230. */
  56231. constructor(
  56232. /**
  56233. * Defines the scene to instrument
  56234. */
  56235. scene: Scene);
  56236. /**
  56237. * Dispose and release associated resources.
  56238. */
  56239. dispose(): void;
  56240. }
  56241. }
  56242. declare module BABYLON {
  56243. /** @hidden */
  56244. export var glowMapGenerationPixelShader: {
  56245. name: string;
  56246. shader: string;
  56247. };
  56248. }
  56249. declare module BABYLON {
  56250. /** @hidden */
  56251. export var glowMapGenerationVertexShader: {
  56252. name: string;
  56253. shader: string;
  56254. };
  56255. }
  56256. declare module BABYLON {
  56257. /**
  56258. * Effect layer options. This helps customizing the behaviour
  56259. * of the effect layer.
  56260. */
  56261. export interface IEffectLayerOptions {
  56262. /**
  56263. * Multiplication factor apply to the canvas size to compute the render target size
  56264. * used to generated the objects (the smaller the faster).
  56265. */
  56266. mainTextureRatio: number;
  56267. /**
  56268. * Enforces a fixed size texture to ensure effect stability across devices.
  56269. */
  56270. mainTextureFixedSize?: number;
  56271. /**
  56272. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  56273. */
  56274. alphaBlendingMode: number;
  56275. /**
  56276. * The camera attached to the layer.
  56277. */
  56278. camera: Nullable<Camera>;
  56279. /**
  56280. * The rendering group to draw the layer in.
  56281. */
  56282. renderingGroupId: number;
  56283. }
  56284. /**
  56285. * The effect layer Helps adding post process effect blended with the main pass.
  56286. *
  56287. * This can be for instance use to generate glow or higlight effects on the scene.
  56288. *
  56289. * The effect layer class can not be used directly and is intented to inherited from to be
  56290. * customized per effects.
  56291. */
  56292. export abstract class EffectLayer {
  56293. private _vertexBuffers;
  56294. private _indexBuffer;
  56295. private _cachedDefines;
  56296. private _effectLayerMapGenerationEffect;
  56297. private _effectLayerOptions;
  56298. private _mergeEffect;
  56299. protected _scene: Scene;
  56300. protected _engine: Engine;
  56301. protected _maxSize: number;
  56302. protected _mainTextureDesiredSize: ISize;
  56303. protected _mainTexture: RenderTargetTexture;
  56304. protected _shouldRender: boolean;
  56305. protected _postProcesses: PostProcess[];
  56306. protected _textures: BaseTexture[];
  56307. protected _emissiveTextureAndColor: {
  56308. texture: Nullable<BaseTexture>;
  56309. color: Color4;
  56310. };
  56311. /**
  56312. * The name of the layer
  56313. */
  56314. name: string;
  56315. /**
  56316. * The clear color of the texture used to generate the glow map.
  56317. */
  56318. neutralColor: Color4;
  56319. /**
  56320. * Specifies whether the highlight layer is enabled or not.
  56321. */
  56322. isEnabled: boolean;
  56323. /**
  56324. * Gets the camera attached to the layer.
  56325. */
  56326. get camera(): Nullable<Camera>;
  56327. /**
  56328. * Gets the rendering group id the layer should render in.
  56329. */
  56330. get renderingGroupId(): number;
  56331. set renderingGroupId(renderingGroupId: number);
  56332. /**
  56333. * An event triggered when the effect layer has been disposed.
  56334. */
  56335. onDisposeObservable: Observable<EffectLayer>;
  56336. /**
  56337. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  56338. */
  56339. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  56340. /**
  56341. * An event triggered when the generated texture is being merged in the scene.
  56342. */
  56343. onBeforeComposeObservable: Observable<EffectLayer>;
  56344. /**
  56345. * An event triggered when the mesh is rendered into the effect render target.
  56346. */
  56347. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  56348. /**
  56349. * An event triggered after the mesh has been rendered into the effect render target.
  56350. */
  56351. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  56352. /**
  56353. * An event triggered when the generated texture has been merged in the scene.
  56354. */
  56355. onAfterComposeObservable: Observable<EffectLayer>;
  56356. /**
  56357. * An event triggered when the efffect layer changes its size.
  56358. */
  56359. onSizeChangedObservable: Observable<EffectLayer>;
  56360. /** @hidden */
  56361. static _SceneComponentInitialization: (scene: Scene) => void;
  56362. /**
  56363. * Instantiates a new effect Layer and references it in the scene.
  56364. * @param name The name of the layer
  56365. * @param scene The scene to use the layer in
  56366. */
  56367. constructor(
  56368. /** The Friendly of the effect in the scene */
  56369. name: string, scene: Scene);
  56370. /**
  56371. * Get the effect name of the layer.
  56372. * @return The effect name
  56373. */
  56374. abstract getEffectName(): string;
  56375. /**
  56376. * Checks for the readiness of the element composing the layer.
  56377. * @param subMesh the mesh to check for
  56378. * @param useInstances specify whether or not to use instances to render the mesh
  56379. * @return true if ready otherwise, false
  56380. */
  56381. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56382. /**
  56383. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  56384. * @returns true if the effect requires stencil during the main canvas render pass.
  56385. */
  56386. abstract needStencil(): boolean;
  56387. /**
  56388. * Create the merge effect. This is the shader use to blit the information back
  56389. * to the main canvas at the end of the scene rendering.
  56390. * @returns The effect containing the shader used to merge the effect on the main canvas
  56391. */
  56392. protected abstract _createMergeEffect(): Effect;
  56393. /**
  56394. * Creates the render target textures and post processes used in the effect layer.
  56395. */
  56396. protected abstract _createTextureAndPostProcesses(): void;
  56397. /**
  56398. * Implementation specific of rendering the generating effect on the main canvas.
  56399. * @param effect The effect used to render through
  56400. */
  56401. protected abstract _internalRender(effect: Effect): void;
  56402. /**
  56403. * Sets the required values for both the emissive texture and and the main color.
  56404. */
  56405. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56406. /**
  56407. * Free any resources and references associated to a mesh.
  56408. * Internal use
  56409. * @param mesh The mesh to free.
  56410. */
  56411. abstract _disposeMesh(mesh: Mesh): void;
  56412. /**
  56413. * Serializes this layer (Glow or Highlight for example)
  56414. * @returns a serialized layer object
  56415. */
  56416. abstract serialize?(): any;
  56417. /**
  56418. * Initializes the effect layer with the required options.
  56419. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  56420. */
  56421. protected _init(options: Partial<IEffectLayerOptions>): void;
  56422. /**
  56423. * Generates the index buffer of the full screen quad blending to the main canvas.
  56424. */
  56425. private _generateIndexBuffer;
  56426. /**
  56427. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  56428. */
  56429. private _generateVertexBuffer;
  56430. /**
  56431. * Sets the main texture desired size which is the closest power of two
  56432. * of the engine canvas size.
  56433. */
  56434. private _setMainTextureSize;
  56435. /**
  56436. * Creates the main texture for the effect layer.
  56437. */
  56438. protected _createMainTexture(): void;
  56439. /**
  56440. * Adds specific effects defines.
  56441. * @param defines The defines to add specifics to.
  56442. */
  56443. protected _addCustomEffectDefines(defines: string[]): void;
  56444. /**
  56445. * Checks for the readiness of the element composing the layer.
  56446. * @param subMesh the mesh to check for
  56447. * @param useInstances specify whether or not to use instances to render the mesh
  56448. * @param emissiveTexture the associated emissive texture used to generate the glow
  56449. * @return true if ready otherwise, false
  56450. */
  56451. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  56452. /**
  56453. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  56454. */
  56455. render(): void;
  56456. /**
  56457. * Determine if a given mesh will be used in the current effect.
  56458. * @param mesh mesh to test
  56459. * @returns true if the mesh will be used
  56460. */
  56461. hasMesh(mesh: AbstractMesh): boolean;
  56462. /**
  56463. * Returns true if the layer contains information to display, otherwise false.
  56464. * @returns true if the glow layer should be rendered
  56465. */
  56466. shouldRender(): boolean;
  56467. /**
  56468. * Returns true if the mesh should render, otherwise false.
  56469. * @param mesh The mesh to render
  56470. * @returns true if it should render otherwise false
  56471. */
  56472. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  56473. /**
  56474. * Returns true if the mesh can be rendered, otherwise false.
  56475. * @param mesh The mesh to render
  56476. * @param material The material used on the mesh
  56477. * @returns true if it can be rendered otherwise false
  56478. */
  56479. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  56480. /**
  56481. * Returns true if the mesh should render, otherwise false.
  56482. * @param mesh The mesh to render
  56483. * @returns true if it should render otherwise false
  56484. */
  56485. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  56486. /**
  56487. * Renders the submesh passed in parameter to the generation map.
  56488. */
  56489. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  56490. /**
  56491. * Defines whether the current material of the mesh should be use to render the effect.
  56492. * @param mesh defines the current mesh to render
  56493. */
  56494. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  56495. /**
  56496. * Rebuild the required buffers.
  56497. * @hidden Internal use only.
  56498. */
  56499. _rebuild(): void;
  56500. /**
  56501. * Dispose only the render target textures and post process.
  56502. */
  56503. private _disposeTextureAndPostProcesses;
  56504. /**
  56505. * Dispose the highlight layer and free resources.
  56506. */
  56507. dispose(): void;
  56508. /**
  56509. * Gets the class name of the effect layer
  56510. * @returns the string with the class name of the effect layer
  56511. */
  56512. getClassName(): string;
  56513. /**
  56514. * Creates an effect layer from parsed effect layer data
  56515. * @param parsedEffectLayer defines effect layer data
  56516. * @param scene defines the current scene
  56517. * @param rootUrl defines the root URL containing the effect layer information
  56518. * @returns a parsed effect Layer
  56519. */
  56520. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  56521. }
  56522. }
  56523. declare module BABYLON {
  56524. interface AbstractScene {
  56525. /**
  56526. * The list of effect layers (highlights/glow) added to the scene
  56527. * @see http://doc.babylonjs.com/how_to/highlight_layer
  56528. * @see http://doc.babylonjs.com/how_to/glow_layer
  56529. */
  56530. effectLayers: Array<EffectLayer>;
  56531. /**
  56532. * Removes the given effect layer from this scene.
  56533. * @param toRemove defines the effect layer to remove
  56534. * @returns the index of the removed effect layer
  56535. */
  56536. removeEffectLayer(toRemove: EffectLayer): number;
  56537. /**
  56538. * Adds the given effect layer to this scene
  56539. * @param newEffectLayer defines the effect layer to add
  56540. */
  56541. addEffectLayer(newEffectLayer: EffectLayer): void;
  56542. }
  56543. /**
  56544. * Defines the layer scene component responsible to manage any effect layers
  56545. * in a given scene.
  56546. */
  56547. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  56548. /**
  56549. * The component name helpfull to identify the component in the list of scene components.
  56550. */
  56551. readonly name: string;
  56552. /**
  56553. * The scene the component belongs to.
  56554. */
  56555. scene: Scene;
  56556. private _engine;
  56557. private _renderEffects;
  56558. private _needStencil;
  56559. private _previousStencilState;
  56560. /**
  56561. * Creates a new instance of the component for the given scene
  56562. * @param scene Defines the scene to register the component in
  56563. */
  56564. constructor(scene: Scene);
  56565. /**
  56566. * Registers the component in a given scene
  56567. */
  56568. register(): void;
  56569. /**
  56570. * Rebuilds the elements related to this component in case of
  56571. * context lost for instance.
  56572. */
  56573. rebuild(): void;
  56574. /**
  56575. * Serializes the component data to the specified json object
  56576. * @param serializationObject The object to serialize to
  56577. */
  56578. serialize(serializationObject: any): void;
  56579. /**
  56580. * Adds all the elements from the container to the scene
  56581. * @param container the container holding the elements
  56582. */
  56583. addFromContainer(container: AbstractScene): void;
  56584. /**
  56585. * Removes all the elements in the container from the scene
  56586. * @param container contains the elements to remove
  56587. * @param dispose if the removed element should be disposed (default: false)
  56588. */
  56589. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56590. /**
  56591. * Disposes the component and the associated ressources.
  56592. */
  56593. dispose(): void;
  56594. private _isReadyForMesh;
  56595. private _renderMainTexture;
  56596. private _setStencil;
  56597. private _setStencilBack;
  56598. private _draw;
  56599. private _drawCamera;
  56600. private _drawRenderingGroup;
  56601. }
  56602. }
  56603. declare module BABYLON {
  56604. /** @hidden */
  56605. export var glowMapMergePixelShader: {
  56606. name: string;
  56607. shader: string;
  56608. };
  56609. }
  56610. declare module BABYLON {
  56611. /** @hidden */
  56612. export var glowMapMergeVertexShader: {
  56613. name: string;
  56614. shader: string;
  56615. };
  56616. }
  56617. declare module BABYLON {
  56618. interface AbstractScene {
  56619. /**
  56620. * Return a the first highlight layer of the scene with a given name.
  56621. * @param name The name of the highlight layer to look for.
  56622. * @return The highlight layer if found otherwise null.
  56623. */
  56624. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  56625. }
  56626. /**
  56627. * Glow layer options. This helps customizing the behaviour
  56628. * of the glow layer.
  56629. */
  56630. export interface IGlowLayerOptions {
  56631. /**
  56632. * Multiplication factor apply to the canvas size to compute the render target size
  56633. * used to generated the glowing objects (the smaller the faster).
  56634. */
  56635. mainTextureRatio: number;
  56636. /**
  56637. * Enforces a fixed size texture to ensure resize independant blur.
  56638. */
  56639. mainTextureFixedSize?: number;
  56640. /**
  56641. * How big is the kernel of the blur texture.
  56642. */
  56643. blurKernelSize: number;
  56644. /**
  56645. * The camera attached to the layer.
  56646. */
  56647. camera: Nullable<Camera>;
  56648. /**
  56649. * Enable MSAA by chosing the number of samples.
  56650. */
  56651. mainTextureSamples?: number;
  56652. /**
  56653. * The rendering group to draw the layer in.
  56654. */
  56655. renderingGroupId: number;
  56656. }
  56657. /**
  56658. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  56659. *
  56660. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  56661. *
  56662. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  56663. */
  56664. export class GlowLayer extends EffectLayer {
  56665. /**
  56666. * Effect Name of the layer.
  56667. */
  56668. static readonly EffectName: string;
  56669. /**
  56670. * The default blur kernel size used for the glow.
  56671. */
  56672. static DefaultBlurKernelSize: number;
  56673. /**
  56674. * The default texture size ratio used for the glow.
  56675. */
  56676. static DefaultTextureRatio: number;
  56677. /**
  56678. * Sets the kernel size of the blur.
  56679. */
  56680. set blurKernelSize(value: number);
  56681. /**
  56682. * Gets the kernel size of the blur.
  56683. */
  56684. get blurKernelSize(): number;
  56685. /**
  56686. * Sets the glow intensity.
  56687. */
  56688. set intensity(value: number);
  56689. /**
  56690. * Gets the glow intensity.
  56691. */
  56692. get intensity(): number;
  56693. private _options;
  56694. private _intensity;
  56695. private _horizontalBlurPostprocess1;
  56696. private _verticalBlurPostprocess1;
  56697. private _horizontalBlurPostprocess2;
  56698. private _verticalBlurPostprocess2;
  56699. private _blurTexture1;
  56700. private _blurTexture2;
  56701. private _postProcesses1;
  56702. private _postProcesses2;
  56703. private _includedOnlyMeshes;
  56704. private _excludedMeshes;
  56705. private _meshesUsingTheirOwnMaterials;
  56706. /**
  56707. * Callback used to let the user override the color selection on a per mesh basis
  56708. */
  56709. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  56710. /**
  56711. * Callback used to let the user override the texture selection on a per mesh basis
  56712. */
  56713. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  56714. /**
  56715. * Instantiates a new glow Layer and references it to the scene.
  56716. * @param name The name of the layer
  56717. * @param scene The scene to use the layer in
  56718. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  56719. */
  56720. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  56721. /**
  56722. * Get the effect name of the layer.
  56723. * @return The effect name
  56724. */
  56725. getEffectName(): string;
  56726. /**
  56727. * Create the merge effect. This is the shader use to blit the information back
  56728. * to the main canvas at the end of the scene rendering.
  56729. */
  56730. protected _createMergeEffect(): Effect;
  56731. /**
  56732. * Creates the render target textures and post processes used in the glow layer.
  56733. */
  56734. protected _createTextureAndPostProcesses(): void;
  56735. /**
  56736. * Checks for the readiness of the element composing the layer.
  56737. * @param subMesh the mesh to check for
  56738. * @param useInstances specify wether or not to use instances to render the mesh
  56739. * @param emissiveTexture the associated emissive texture used to generate the glow
  56740. * @return true if ready otherwise, false
  56741. */
  56742. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56743. /**
  56744. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  56745. */
  56746. needStencil(): boolean;
  56747. /**
  56748. * Returns true if the mesh can be rendered, otherwise false.
  56749. * @param mesh The mesh to render
  56750. * @param material The material used on the mesh
  56751. * @returns true if it can be rendered otherwise false
  56752. */
  56753. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  56754. /**
  56755. * Implementation specific of rendering the generating effect on the main canvas.
  56756. * @param effect The effect used to render through
  56757. */
  56758. protected _internalRender(effect: Effect): void;
  56759. /**
  56760. * Sets the required values for both the emissive texture and and the main color.
  56761. */
  56762. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56763. /**
  56764. * Returns true if the mesh should render, otherwise false.
  56765. * @param mesh The mesh to render
  56766. * @returns true if it should render otherwise false
  56767. */
  56768. protected _shouldRenderMesh(mesh: Mesh): boolean;
  56769. /**
  56770. * Adds specific effects defines.
  56771. * @param defines The defines to add specifics to.
  56772. */
  56773. protected _addCustomEffectDefines(defines: string[]): void;
  56774. /**
  56775. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  56776. * @param mesh The mesh to exclude from the glow layer
  56777. */
  56778. addExcludedMesh(mesh: Mesh): void;
  56779. /**
  56780. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  56781. * @param mesh The mesh to remove
  56782. */
  56783. removeExcludedMesh(mesh: Mesh): void;
  56784. /**
  56785. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  56786. * @param mesh The mesh to include in the glow layer
  56787. */
  56788. addIncludedOnlyMesh(mesh: Mesh): void;
  56789. /**
  56790. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  56791. * @param mesh The mesh to remove
  56792. */
  56793. removeIncludedOnlyMesh(mesh: Mesh): void;
  56794. /**
  56795. * Determine if a given mesh will be used in the glow layer
  56796. * @param mesh The mesh to test
  56797. * @returns true if the mesh will be highlighted by the current glow layer
  56798. */
  56799. hasMesh(mesh: AbstractMesh): boolean;
  56800. /**
  56801. * Defines whether the current material of the mesh should be use to render the effect.
  56802. * @param mesh defines the current mesh to render
  56803. */
  56804. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  56805. /**
  56806. * Add a mesh to be rendered through its own material and not with emissive only.
  56807. * @param mesh The mesh for which we need to use its material
  56808. */
  56809. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  56810. /**
  56811. * Remove a mesh from being rendered through its own material and not with emissive only.
  56812. * @param mesh The mesh for which we need to not use its material
  56813. */
  56814. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  56815. /**
  56816. * Free any resources and references associated to a mesh.
  56817. * Internal use
  56818. * @param mesh The mesh to free.
  56819. * @hidden
  56820. */
  56821. _disposeMesh(mesh: Mesh): void;
  56822. /**
  56823. * Gets the class name of the effect layer
  56824. * @returns the string with the class name of the effect layer
  56825. */
  56826. getClassName(): string;
  56827. /**
  56828. * Serializes this glow layer
  56829. * @returns a serialized glow layer object
  56830. */
  56831. serialize(): any;
  56832. /**
  56833. * Creates a Glow Layer from parsed glow layer data
  56834. * @param parsedGlowLayer defines glow layer data
  56835. * @param scene defines the current scene
  56836. * @param rootUrl defines the root URL containing the glow layer information
  56837. * @returns a parsed Glow Layer
  56838. */
  56839. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  56840. }
  56841. }
  56842. declare module BABYLON {
  56843. /** @hidden */
  56844. export var glowBlurPostProcessPixelShader: {
  56845. name: string;
  56846. shader: string;
  56847. };
  56848. }
  56849. declare module BABYLON {
  56850. interface AbstractScene {
  56851. /**
  56852. * Return a the first highlight layer of the scene with a given name.
  56853. * @param name The name of the highlight layer to look for.
  56854. * @return The highlight layer if found otherwise null.
  56855. */
  56856. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  56857. }
  56858. /**
  56859. * Highlight layer options. This helps customizing the behaviour
  56860. * of the highlight layer.
  56861. */
  56862. export interface IHighlightLayerOptions {
  56863. /**
  56864. * Multiplication factor apply to the canvas size to compute the render target size
  56865. * used to generated the glowing objects (the smaller the faster).
  56866. */
  56867. mainTextureRatio: number;
  56868. /**
  56869. * Enforces a fixed size texture to ensure resize independant blur.
  56870. */
  56871. mainTextureFixedSize?: number;
  56872. /**
  56873. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  56874. * of the picture to blur (the smaller the faster).
  56875. */
  56876. blurTextureSizeRatio: number;
  56877. /**
  56878. * How big in texel of the blur texture is the vertical blur.
  56879. */
  56880. blurVerticalSize: number;
  56881. /**
  56882. * How big in texel of the blur texture is the horizontal blur.
  56883. */
  56884. blurHorizontalSize: number;
  56885. /**
  56886. * Alpha blending mode used to apply the blur. Default is combine.
  56887. */
  56888. alphaBlendingMode: number;
  56889. /**
  56890. * The camera attached to the layer.
  56891. */
  56892. camera: Nullable<Camera>;
  56893. /**
  56894. * Should we display highlight as a solid stroke?
  56895. */
  56896. isStroke?: boolean;
  56897. /**
  56898. * The rendering group to draw the layer in.
  56899. */
  56900. renderingGroupId: number;
  56901. }
  56902. /**
  56903. * The highlight layer Helps adding a glow effect around a mesh.
  56904. *
  56905. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  56906. * glowy meshes to your scene.
  56907. *
  56908. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  56909. */
  56910. export class HighlightLayer extends EffectLayer {
  56911. name: string;
  56912. /**
  56913. * Effect Name of the highlight layer.
  56914. */
  56915. static readonly EffectName: string;
  56916. /**
  56917. * The neutral color used during the preparation of the glow effect.
  56918. * This is black by default as the blend operation is a blend operation.
  56919. */
  56920. static NeutralColor: Color4;
  56921. /**
  56922. * Stencil value used for glowing meshes.
  56923. */
  56924. static GlowingMeshStencilReference: number;
  56925. /**
  56926. * Stencil value used for the other meshes in the scene.
  56927. */
  56928. static NormalMeshStencilReference: number;
  56929. /**
  56930. * Specifies whether or not the inner glow is ACTIVE in the layer.
  56931. */
  56932. innerGlow: boolean;
  56933. /**
  56934. * Specifies whether or not the outer glow is ACTIVE in the layer.
  56935. */
  56936. outerGlow: boolean;
  56937. /**
  56938. * Specifies the horizontal size of the blur.
  56939. */
  56940. set blurHorizontalSize(value: number);
  56941. /**
  56942. * Specifies the vertical size of the blur.
  56943. */
  56944. set blurVerticalSize(value: number);
  56945. /**
  56946. * Gets the horizontal size of the blur.
  56947. */
  56948. get blurHorizontalSize(): number;
  56949. /**
  56950. * Gets the vertical size of the blur.
  56951. */
  56952. get blurVerticalSize(): number;
  56953. /**
  56954. * An event triggered when the highlight layer is being blurred.
  56955. */
  56956. onBeforeBlurObservable: Observable<HighlightLayer>;
  56957. /**
  56958. * An event triggered when the highlight layer has been blurred.
  56959. */
  56960. onAfterBlurObservable: Observable<HighlightLayer>;
  56961. private _instanceGlowingMeshStencilReference;
  56962. private _options;
  56963. private _downSamplePostprocess;
  56964. private _horizontalBlurPostprocess;
  56965. private _verticalBlurPostprocess;
  56966. private _blurTexture;
  56967. private _meshes;
  56968. private _excludedMeshes;
  56969. /**
  56970. * Instantiates a new highlight Layer and references it to the scene..
  56971. * @param name The name of the layer
  56972. * @param scene The scene to use the layer in
  56973. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  56974. */
  56975. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  56976. /**
  56977. * Get the effect name of the layer.
  56978. * @return The effect name
  56979. */
  56980. getEffectName(): string;
  56981. /**
  56982. * Create the merge effect. This is the shader use to blit the information back
  56983. * to the main canvas at the end of the scene rendering.
  56984. */
  56985. protected _createMergeEffect(): Effect;
  56986. /**
  56987. * Creates the render target textures and post processes used in the highlight layer.
  56988. */
  56989. protected _createTextureAndPostProcesses(): void;
  56990. /**
  56991. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  56992. */
  56993. needStencil(): boolean;
  56994. /**
  56995. * Checks for the readiness of the element composing the layer.
  56996. * @param subMesh the mesh to check for
  56997. * @param useInstances specify wether or not to use instances to render the mesh
  56998. * @param emissiveTexture the associated emissive texture used to generate the glow
  56999. * @return true if ready otherwise, false
  57000. */
  57001. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57002. /**
  57003. * Implementation specific of rendering the generating effect on the main canvas.
  57004. * @param effect The effect used to render through
  57005. */
  57006. protected _internalRender(effect: Effect): void;
  57007. /**
  57008. * Returns true if the layer contains information to display, otherwise false.
  57009. */
  57010. shouldRender(): boolean;
  57011. /**
  57012. * Returns true if the mesh should render, otherwise false.
  57013. * @param mesh The mesh to render
  57014. * @returns true if it should render otherwise false
  57015. */
  57016. protected _shouldRenderMesh(mesh: Mesh): boolean;
  57017. /**
  57018. * Adds specific effects defines.
  57019. * @param defines The defines to add specifics to.
  57020. */
  57021. protected _addCustomEffectDefines(defines: string[]): void;
  57022. /**
  57023. * Sets the required values for both the emissive texture and and the main color.
  57024. */
  57025. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57026. /**
  57027. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  57028. * @param mesh The mesh to exclude from the highlight layer
  57029. */
  57030. addExcludedMesh(mesh: Mesh): void;
  57031. /**
  57032. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  57033. * @param mesh The mesh to highlight
  57034. */
  57035. removeExcludedMesh(mesh: Mesh): void;
  57036. /**
  57037. * Determine if a given mesh will be highlighted by the current HighlightLayer
  57038. * @param mesh mesh to test
  57039. * @returns true if the mesh will be highlighted by the current HighlightLayer
  57040. */
  57041. hasMesh(mesh: AbstractMesh): boolean;
  57042. /**
  57043. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  57044. * @param mesh The mesh to highlight
  57045. * @param color The color of the highlight
  57046. * @param glowEmissiveOnly Extract the glow from the emissive texture
  57047. */
  57048. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  57049. /**
  57050. * Remove a mesh from the highlight layer in order to make it stop glowing.
  57051. * @param mesh The mesh to highlight
  57052. */
  57053. removeMesh(mesh: Mesh): void;
  57054. /**
  57055. * Remove all the meshes currently referenced in the highlight layer
  57056. */
  57057. removeAllMeshes(): void;
  57058. /**
  57059. * Force the stencil to the normal expected value for none glowing parts
  57060. */
  57061. private _defaultStencilReference;
  57062. /**
  57063. * Free any resources and references associated to a mesh.
  57064. * Internal use
  57065. * @param mesh The mesh to free.
  57066. * @hidden
  57067. */
  57068. _disposeMesh(mesh: Mesh): void;
  57069. /**
  57070. * Dispose the highlight layer and free resources.
  57071. */
  57072. dispose(): void;
  57073. /**
  57074. * Gets the class name of the effect layer
  57075. * @returns the string with the class name of the effect layer
  57076. */
  57077. getClassName(): string;
  57078. /**
  57079. * Serializes this Highlight layer
  57080. * @returns a serialized Highlight layer object
  57081. */
  57082. serialize(): any;
  57083. /**
  57084. * Creates a Highlight layer from parsed Highlight layer data
  57085. * @param parsedHightlightLayer defines the Highlight layer data
  57086. * @param scene defines the current scene
  57087. * @param rootUrl defines the root URL containing the Highlight layer information
  57088. * @returns a parsed Highlight layer
  57089. */
  57090. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  57091. }
  57092. }
  57093. declare module BABYLON {
  57094. interface AbstractScene {
  57095. /**
  57096. * The list of layers (background and foreground) of the scene
  57097. */
  57098. layers: Array<Layer>;
  57099. }
  57100. /**
  57101. * Defines the layer scene component responsible to manage any layers
  57102. * in a given scene.
  57103. */
  57104. export class LayerSceneComponent implements ISceneComponent {
  57105. /**
  57106. * The component name helpfull to identify the component in the list of scene components.
  57107. */
  57108. readonly name: string;
  57109. /**
  57110. * The scene the component belongs to.
  57111. */
  57112. scene: Scene;
  57113. private _engine;
  57114. /**
  57115. * Creates a new instance of the component for the given scene
  57116. * @param scene Defines the scene to register the component in
  57117. */
  57118. constructor(scene: Scene);
  57119. /**
  57120. * Registers the component in a given scene
  57121. */
  57122. register(): void;
  57123. /**
  57124. * Rebuilds the elements related to this component in case of
  57125. * context lost for instance.
  57126. */
  57127. rebuild(): void;
  57128. /**
  57129. * Disposes the component and the associated ressources.
  57130. */
  57131. dispose(): void;
  57132. private _draw;
  57133. private _drawCameraPredicate;
  57134. private _drawCameraBackground;
  57135. private _drawCameraForeground;
  57136. private _drawRenderTargetPredicate;
  57137. private _drawRenderTargetBackground;
  57138. private _drawRenderTargetForeground;
  57139. /**
  57140. * Adds all the elements from the container to the scene
  57141. * @param container the container holding the elements
  57142. */
  57143. addFromContainer(container: AbstractScene): void;
  57144. /**
  57145. * Removes all the elements in the container from the scene
  57146. * @param container contains the elements to remove
  57147. * @param dispose if the removed element should be disposed (default: false)
  57148. */
  57149. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57150. }
  57151. }
  57152. declare module BABYLON {
  57153. /** @hidden */
  57154. export var layerPixelShader: {
  57155. name: string;
  57156. shader: string;
  57157. };
  57158. }
  57159. declare module BABYLON {
  57160. /** @hidden */
  57161. export var layerVertexShader: {
  57162. name: string;
  57163. shader: string;
  57164. };
  57165. }
  57166. declare module BABYLON {
  57167. /**
  57168. * This represents a full screen 2d layer.
  57169. * This can be useful to display a picture in the background of your scene for instance.
  57170. * @see https://www.babylonjs-playground.com/#08A2BS#1
  57171. */
  57172. export class Layer {
  57173. /**
  57174. * Define the name of the layer.
  57175. */
  57176. name: string;
  57177. /**
  57178. * Define the texture the layer should display.
  57179. */
  57180. texture: Nullable<Texture>;
  57181. /**
  57182. * Is the layer in background or foreground.
  57183. */
  57184. isBackground: boolean;
  57185. /**
  57186. * Define the color of the layer (instead of texture).
  57187. */
  57188. color: Color4;
  57189. /**
  57190. * Define the scale of the layer in order to zoom in out of the texture.
  57191. */
  57192. scale: Vector2;
  57193. /**
  57194. * Define an offset for the layer in order to shift the texture.
  57195. */
  57196. offset: Vector2;
  57197. /**
  57198. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  57199. */
  57200. alphaBlendingMode: number;
  57201. /**
  57202. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  57203. * Alpha test will not mix with the background color in case of transparency.
  57204. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  57205. */
  57206. alphaTest: boolean;
  57207. /**
  57208. * Define a mask to restrict the layer to only some of the scene cameras.
  57209. */
  57210. layerMask: number;
  57211. /**
  57212. * Define the list of render target the layer is visible into.
  57213. */
  57214. renderTargetTextures: RenderTargetTexture[];
  57215. /**
  57216. * Define if the layer is only used in renderTarget or if it also
  57217. * renders in the main frame buffer of the canvas.
  57218. */
  57219. renderOnlyInRenderTargetTextures: boolean;
  57220. private _scene;
  57221. private _vertexBuffers;
  57222. private _indexBuffer;
  57223. private _effect;
  57224. private _previousDefines;
  57225. /**
  57226. * An event triggered when the layer is disposed.
  57227. */
  57228. onDisposeObservable: Observable<Layer>;
  57229. private _onDisposeObserver;
  57230. /**
  57231. * Back compatibility with callback before the onDisposeObservable existed.
  57232. * The set callback will be triggered when the layer has been disposed.
  57233. */
  57234. set onDispose(callback: () => void);
  57235. /**
  57236. * An event triggered before rendering the scene
  57237. */
  57238. onBeforeRenderObservable: Observable<Layer>;
  57239. private _onBeforeRenderObserver;
  57240. /**
  57241. * Back compatibility with callback before the onBeforeRenderObservable existed.
  57242. * The set callback will be triggered just before rendering the layer.
  57243. */
  57244. set onBeforeRender(callback: () => void);
  57245. /**
  57246. * An event triggered after rendering the scene
  57247. */
  57248. onAfterRenderObservable: Observable<Layer>;
  57249. private _onAfterRenderObserver;
  57250. /**
  57251. * Back compatibility with callback before the onAfterRenderObservable existed.
  57252. * The set callback will be triggered just after rendering the layer.
  57253. */
  57254. set onAfterRender(callback: () => void);
  57255. /**
  57256. * Instantiates a new layer.
  57257. * This represents a full screen 2d layer.
  57258. * This can be useful to display a picture in the background of your scene for instance.
  57259. * @see https://www.babylonjs-playground.com/#08A2BS#1
  57260. * @param name Define the name of the layer in the scene
  57261. * @param imgUrl Define the url of the texture to display in the layer
  57262. * @param scene Define the scene the layer belongs to
  57263. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  57264. * @param color Defines a color for the layer
  57265. */
  57266. constructor(
  57267. /**
  57268. * Define the name of the layer.
  57269. */
  57270. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  57271. private _createIndexBuffer;
  57272. /** @hidden */
  57273. _rebuild(): void;
  57274. /**
  57275. * Renders the layer in the scene.
  57276. */
  57277. render(): void;
  57278. /**
  57279. * Disposes and releases the associated ressources.
  57280. */
  57281. dispose(): void;
  57282. }
  57283. }
  57284. declare module BABYLON {
  57285. /** @hidden */
  57286. export var lensFlarePixelShader: {
  57287. name: string;
  57288. shader: string;
  57289. };
  57290. }
  57291. declare module BABYLON {
  57292. /** @hidden */
  57293. export var lensFlareVertexShader: {
  57294. name: string;
  57295. shader: string;
  57296. };
  57297. }
  57298. declare module BABYLON {
  57299. /**
  57300. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  57301. * It is usually composed of several `lensFlare`.
  57302. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57303. */
  57304. export class LensFlareSystem {
  57305. /**
  57306. * Define the name of the lens flare system
  57307. */
  57308. name: string;
  57309. /**
  57310. * List of lens flares used in this system.
  57311. */
  57312. lensFlares: LensFlare[];
  57313. /**
  57314. * Define a limit from the border the lens flare can be visible.
  57315. */
  57316. borderLimit: number;
  57317. /**
  57318. * Define a viewport border we do not want to see the lens flare in.
  57319. */
  57320. viewportBorder: number;
  57321. /**
  57322. * Define a predicate which could limit the list of meshes able to occlude the effect.
  57323. */
  57324. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  57325. /**
  57326. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  57327. */
  57328. layerMask: number;
  57329. /**
  57330. * Define the id of the lens flare system in the scene.
  57331. * (equal to name by default)
  57332. */
  57333. id: string;
  57334. private _scene;
  57335. private _emitter;
  57336. private _vertexBuffers;
  57337. private _indexBuffer;
  57338. private _effect;
  57339. private _positionX;
  57340. private _positionY;
  57341. private _isEnabled;
  57342. /** @hidden */
  57343. static _SceneComponentInitialization: (scene: Scene) => void;
  57344. /**
  57345. * Instantiates a lens flare system.
  57346. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  57347. * It is usually composed of several `lensFlare`.
  57348. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57349. * @param name Define the name of the lens flare system in the scene
  57350. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  57351. * @param scene Define the scene the lens flare system belongs to
  57352. */
  57353. constructor(
  57354. /**
  57355. * Define the name of the lens flare system
  57356. */
  57357. name: string, emitter: any, scene: Scene);
  57358. /**
  57359. * Define if the lens flare system is enabled.
  57360. */
  57361. get isEnabled(): boolean;
  57362. set isEnabled(value: boolean);
  57363. /**
  57364. * Get the scene the effects belongs to.
  57365. * @returns the scene holding the lens flare system
  57366. */
  57367. getScene(): Scene;
  57368. /**
  57369. * Get the emitter of the lens flare system.
  57370. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57371. * @returns the emitter of the lens flare system
  57372. */
  57373. getEmitter(): any;
  57374. /**
  57375. * Set the emitter of the lens flare system.
  57376. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57377. * @param newEmitter Define the new emitter of the system
  57378. */
  57379. setEmitter(newEmitter: any): void;
  57380. /**
  57381. * Get the lens flare system emitter position.
  57382. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  57383. * @returns the position
  57384. */
  57385. getEmitterPosition(): Vector3;
  57386. /**
  57387. * @hidden
  57388. */
  57389. computeEffectivePosition(globalViewport: Viewport): boolean;
  57390. /** @hidden */
  57391. _isVisible(): boolean;
  57392. /**
  57393. * @hidden
  57394. */
  57395. render(): boolean;
  57396. /**
  57397. * Dispose and release the lens flare with its associated resources.
  57398. */
  57399. dispose(): void;
  57400. /**
  57401. * Parse a lens flare system from a JSON repressentation
  57402. * @param parsedLensFlareSystem Define the JSON to parse
  57403. * @param scene Define the scene the parsed system should be instantiated in
  57404. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  57405. * @returns the parsed system
  57406. */
  57407. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  57408. /**
  57409. * Serialize the current Lens Flare System into a JSON representation.
  57410. * @returns the serialized JSON
  57411. */
  57412. serialize(): any;
  57413. }
  57414. }
  57415. declare module BABYLON {
  57416. /**
  57417. * This represents one of the lens effect in a `lensFlareSystem`.
  57418. * It controls one of the indiviual texture used in the effect.
  57419. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57420. */
  57421. export class LensFlare {
  57422. /**
  57423. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  57424. */
  57425. size: number;
  57426. /**
  57427. * 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.
  57428. */
  57429. position: number;
  57430. /**
  57431. * Define the lens color.
  57432. */
  57433. color: Color3;
  57434. /**
  57435. * Define the lens texture.
  57436. */
  57437. texture: Nullable<Texture>;
  57438. /**
  57439. * Define the alpha mode to render this particular lens.
  57440. */
  57441. alphaMode: number;
  57442. private _system;
  57443. /**
  57444. * Creates a new Lens Flare.
  57445. * This represents one of the lens effect in a `lensFlareSystem`.
  57446. * It controls one of the indiviual texture used in the effect.
  57447. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57448. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  57449. * @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.
  57450. * @param color Define the lens color
  57451. * @param imgUrl Define the lens texture url
  57452. * @param system Define the `lensFlareSystem` this flare is part of
  57453. * @returns The newly created Lens Flare
  57454. */
  57455. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  57456. /**
  57457. * Instantiates a new Lens Flare.
  57458. * This represents one of the lens effect in a `lensFlareSystem`.
  57459. * It controls one of the indiviual texture used in the effect.
  57460. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57461. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  57462. * @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.
  57463. * @param color Define the lens color
  57464. * @param imgUrl Define the lens texture url
  57465. * @param system Define the `lensFlareSystem` this flare is part of
  57466. */
  57467. constructor(
  57468. /**
  57469. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  57470. */
  57471. size: number,
  57472. /**
  57473. * 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.
  57474. */
  57475. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  57476. /**
  57477. * Dispose and release the lens flare with its associated resources.
  57478. */
  57479. dispose(): void;
  57480. }
  57481. }
  57482. declare module BABYLON {
  57483. interface AbstractScene {
  57484. /**
  57485. * The list of lens flare system added to the scene
  57486. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57487. */
  57488. lensFlareSystems: Array<LensFlareSystem>;
  57489. /**
  57490. * Removes the given lens flare system from this scene.
  57491. * @param toRemove The lens flare system to remove
  57492. * @returns The index of the removed lens flare system
  57493. */
  57494. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  57495. /**
  57496. * Adds the given lens flare system to this scene
  57497. * @param newLensFlareSystem The lens flare system to add
  57498. */
  57499. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  57500. /**
  57501. * Gets a lens flare system using its name
  57502. * @param name defines the name to look for
  57503. * @returns the lens flare system or null if not found
  57504. */
  57505. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  57506. /**
  57507. * Gets a lens flare system using its id
  57508. * @param id defines the id to look for
  57509. * @returns the lens flare system or null if not found
  57510. */
  57511. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  57512. }
  57513. /**
  57514. * Defines the lens flare scene component responsible to manage any lens flares
  57515. * in a given scene.
  57516. */
  57517. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  57518. /**
  57519. * The component name helpfull to identify the component in the list of scene components.
  57520. */
  57521. readonly name: string;
  57522. /**
  57523. * The scene the component belongs to.
  57524. */
  57525. scene: Scene;
  57526. /**
  57527. * Creates a new instance of the component for the given scene
  57528. * @param scene Defines the scene to register the component in
  57529. */
  57530. constructor(scene: Scene);
  57531. /**
  57532. * Registers the component in a given scene
  57533. */
  57534. register(): void;
  57535. /**
  57536. * Rebuilds the elements related to this component in case of
  57537. * context lost for instance.
  57538. */
  57539. rebuild(): void;
  57540. /**
  57541. * Adds all the elements from the container to the scene
  57542. * @param container the container holding the elements
  57543. */
  57544. addFromContainer(container: AbstractScene): void;
  57545. /**
  57546. * Removes all the elements in the container from the scene
  57547. * @param container contains the elements to remove
  57548. * @param dispose if the removed element should be disposed (default: false)
  57549. */
  57550. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57551. /**
  57552. * Serializes the component data to the specified json object
  57553. * @param serializationObject The object to serialize to
  57554. */
  57555. serialize(serializationObject: any): void;
  57556. /**
  57557. * Disposes the component and the associated ressources.
  57558. */
  57559. dispose(): void;
  57560. private _draw;
  57561. }
  57562. }
  57563. declare module BABYLON {
  57564. /** @hidden */
  57565. export var depthPixelShader: {
  57566. name: string;
  57567. shader: string;
  57568. };
  57569. }
  57570. declare module BABYLON {
  57571. /** @hidden */
  57572. export var depthVertexShader: {
  57573. name: string;
  57574. shader: string;
  57575. };
  57576. }
  57577. declare module BABYLON {
  57578. /**
  57579. * This represents a depth renderer in Babylon.
  57580. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  57581. */
  57582. export class DepthRenderer {
  57583. private _scene;
  57584. private _depthMap;
  57585. private _effect;
  57586. private readonly _storeNonLinearDepth;
  57587. private readonly _clearColor;
  57588. /** Get if the depth renderer is using packed depth or not */
  57589. readonly isPacked: boolean;
  57590. private _cachedDefines;
  57591. private _camera;
  57592. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  57593. enabled: boolean;
  57594. /**
  57595. * Specifiess that the depth renderer will only be used within
  57596. * the camera it is created for.
  57597. * This can help forcing its rendering during the camera processing.
  57598. */
  57599. useOnlyInActiveCamera: boolean;
  57600. /** @hidden */
  57601. static _SceneComponentInitialization: (scene: Scene) => void;
  57602. /**
  57603. * Instantiates a depth renderer
  57604. * @param scene The scene the renderer belongs to
  57605. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  57606. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  57607. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  57608. */
  57609. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  57610. /**
  57611. * Creates the depth rendering effect and checks if the effect is ready.
  57612. * @param subMesh The submesh to be used to render the depth map of
  57613. * @param useInstances If multiple world instances should be used
  57614. * @returns if the depth renderer is ready to render the depth map
  57615. */
  57616. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57617. /**
  57618. * Gets the texture which the depth map will be written to.
  57619. * @returns The depth map texture
  57620. */
  57621. getDepthMap(): RenderTargetTexture;
  57622. /**
  57623. * Disposes of the depth renderer.
  57624. */
  57625. dispose(): void;
  57626. }
  57627. }
  57628. declare module BABYLON {
  57629. /** @hidden */
  57630. export var minmaxReduxPixelShader: {
  57631. name: string;
  57632. shader: string;
  57633. };
  57634. }
  57635. declare module BABYLON {
  57636. /**
  57637. * This class computes a min/max reduction from a texture: it means it computes the minimum
  57638. * and maximum values from all values of the texture.
  57639. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  57640. * The source values are read from the red channel of the texture.
  57641. */
  57642. export class MinMaxReducer {
  57643. /**
  57644. * Observable triggered when the computation has been performed
  57645. */
  57646. onAfterReductionPerformed: Observable<{
  57647. min: number;
  57648. max: number;
  57649. }>;
  57650. protected _camera: Camera;
  57651. protected _sourceTexture: Nullable<RenderTargetTexture>;
  57652. protected _reductionSteps: Nullable<Array<PostProcess>>;
  57653. protected _postProcessManager: PostProcessManager;
  57654. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  57655. protected _forceFullscreenViewport: boolean;
  57656. /**
  57657. * Creates a min/max reducer
  57658. * @param camera The camera to use for the post processes
  57659. */
  57660. constructor(camera: Camera);
  57661. /**
  57662. * Gets the texture used to read the values from.
  57663. */
  57664. get sourceTexture(): Nullable<RenderTargetTexture>;
  57665. /**
  57666. * Sets the source texture to read the values from.
  57667. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  57668. * because in such textures '1' value must not be taken into account to compute the maximum
  57669. * as this value is used to clear the texture.
  57670. * Note that the computation is not activated by calling this function, you must call activate() for that!
  57671. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  57672. * @param depthRedux Indicates if the texture is a depth texture or not
  57673. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  57674. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  57675. */
  57676. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  57677. /**
  57678. * Defines the refresh rate of the computation.
  57679. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  57680. */
  57681. get refreshRate(): number;
  57682. set refreshRate(value: number);
  57683. protected _activated: boolean;
  57684. /**
  57685. * Gets the activation status of the reducer
  57686. */
  57687. get activated(): boolean;
  57688. /**
  57689. * Activates the reduction computation.
  57690. * When activated, the observers registered in onAfterReductionPerformed are
  57691. * called after the compuation is performed
  57692. */
  57693. activate(): void;
  57694. /**
  57695. * Deactivates the reduction computation.
  57696. */
  57697. deactivate(): void;
  57698. /**
  57699. * Disposes the min/max reducer
  57700. * @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.
  57701. */
  57702. dispose(disposeAll?: boolean): void;
  57703. }
  57704. }
  57705. declare module BABYLON {
  57706. /**
  57707. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  57708. */
  57709. export class DepthReducer extends MinMaxReducer {
  57710. private _depthRenderer;
  57711. private _depthRendererId;
  57712. /**
  57713. * Gets the depth renderer used for the computation.
  57714. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  57715. */
  57716. get depthRenderer(): Nullable<DepthRenderer>;
  57717. /**
  57718. * Creates a depth reducer
  57719. * @param camera The camera used to render the depth texture
  57720. */
  57721. constructor(camera: Camera);
  57722. /**
  57723. * Sets the depth renderer to use to generate the depth map
  57724. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  57725. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  57726. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  57727. */
  57728. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  57729. /** @hidden */
  57730. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  57731. /**
  57732. * Activates the reduction computation.
  57733. * When activated, the observers registered in onAfterReductionPerformed are
  57734. * called after the compuation is performed
  57735. */
  57736. activate(): void;
  57737. /**
  57738. * Deactivates the reduction computation.
  57739. */
  57740. deactivate(): void;
  57741. /**
  57742. * Disposes the depth reducer
  57743. * @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.
  57744. */
  57745. dispose(disposeAll?: boolean): void;
  57746. }
  57747. }
  57748. declare module BABYLON {
  57749. /**
  57750. * A CSM implementation allowing casting shadows on large scenes.
  57751. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  57752. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  57753. */
  57754. export class CascadedShadowGenerator extends ShadowGenerator {
  57755. private static readonly frustumCornersNDCSpace;
  57756. /**
  57757. * Name of the CSM class
  57758. */
  57759. static CLASSNAME: string;
  57760. /**
  57761. * Defines the default number of cascades used by the CSM.
  57762. */
  57763. static readonly DEFAULT_CASCADES_COUNT: number;
  57764. /**
  57765. * Defines the minimum number of cascades used by the CSM.
  57766. */
  57767. static readonly MIN_CASCADES_COUNT: number;
  57768. /**
  57769. * Defines the maximum number of cascades used by the CSM.
  57770. */
  57771. static readonly MAX_CASCADES_COUNT: number;
  57772. protected _validateFilter(filter: number): number;
  57773. /**
  57774. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  57775. */
  57776. penumbraDarkness: number;
  57777. private _numCascades;
  57778. /**
  57779. * Gets or set the number of cascades used by the CSM.
  57780. */
  57781. get numCascades(): number;
  57782. set numCascades(value: number);
  57783. /**
  57784. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  57785. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  57786. */
  57787. stabilizeCascades: boolean;
  57788. private _freezeShadowCastersBoundingInfo;
  57789. private _freezeShadowCastersBoundingInfoObservable;
  57790. /**
  57791. * Enables or disables the shadow casters bounding info computation.
  57792. * If your shadow casters don't move, you can disable this feature.
  57793. * If it is enabled, the bounding box computation is done every frame.
  57794. */
  57795. get freezeShadowCastersBoundingInfo(): boolean;
  57796. set freezeShadowCastersBoundingInfo(freeze: boolean);
  57797. private _scbiMin;
  57798. private _scbiMax;
  57799. protected _computeShadowCastersBoundingInfo(): void;
  57800. protected _shadowCastersBoundingInfo: BoundingInfo;
  57801. /**
  57802. * Gets or sets the shadow casters bounding info.
  57803. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  57804. * so that the system won't overwrite the bounds you provide
  57805. */
  57806. get shadowCastersBoundingInfo(): BoundingInfo;
  57807. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  57808. protected _breaksAreDirty: boolean;
  57809. protected _minDistance: number;
  57810. protected _maxDistance: number;
  57811. /**
  57812. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  57813. *
  57814. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  57815. * If you don't know these values, simply leave them to their defaults and don't call this function.
  57816. * @param min minimal distance for the breaks (default to 0.)
  57817. * @param max maximal distance for the breaks (default to 1.)
  57818. */
  57819. setMinMaxDistance(min: number, max: number): void;
  57820. /** Gets the minimal distance used in the cascade break computation */
  57821. get minDistance(): number;
  57822. /** Gets the maximal distance used in the cascade break computation */
  57823. get maxDistance(): number;
  57824. /**
  57825. * Gets the class name of that object
  57826. * @returns "CascadedShadowGenerator"
  57827. */
  57828. getClassName(): string;
  57829. private _cascadeMinExtents;
  57830. private _cascadeMaxExtents;
  57831. /**
  57832. * Gets a cascade minimum extents
  57833. * @param cascadeIndex index of the cascade
  57834. * @returns the minimum cascade extents
  57835. */
  57836. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  57837. /**
  57838. * Gets a cascade maximum extents
  57839. * @param cascadeIndex index of the cascade
  57840. * @returns the maximum cascade extents
  57841. */
  57842. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  57843. private _cascades;
  57844. private _currentLayer;
  57845. private _viewSpaceFrustumsZ;
  57846. private _viewMatrices;
  57847. private _projectionMatrices;
  57848. private _transformMatrices;
  57849. private _transformMatricesAsArray;
  57850. private _frustumLengths;
  57851. private _lightSizeUVCorrection;
  57852. private _depthCorrection;
  57853. private _frustumCornersWorldSpace;
  57854. private _frustumCenter;
  57855. private _shadowCameraPos;
  57856. private _shadowMaxZ;
  57857. /**
  57858. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  57859. * It defaults to camera.maxZ
  57860. */
  57861. get shadowMaxZ(): number;
  57862. /**
  57863. * Sets the shadow max z distance.
  57864. */
  57865. set shadowMaxZ(value: number);
  57866. protected _debug: boolean;
  57867. /**
  57868. * Gets or sets the debug flag.
  57869. * When enabled, the cascades are materialized by different colors on the screen.
  57870. */
  57871. get debug(): boolean;
  57872. set debug(dbg: boolean);
  57873. private _depthClamp;
  57874. /**
  57875. * Gets or sets the depth clamping value.
  57876. *
  57877. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  57878. * to account for the shadow casters far away.
  57879. *
  57880. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  57881. */
  57882. get depthClamp(): boolean;
  57883. set depthClamp(value: boolean);
  57884. private _cascadeBlendPercentage;
  57885. /**
  57886. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  57887. * It defaults to 0.1 (10% blending).
  57888. */
  57889. get cascadeBlendPercentage(): number;
  57890. set cascadeBlendPercentage(value: number);
  57891. private _lambda;
  57892. /**
  57893. * Gets or set the lambda parameter.
  57894. * This parameter is used to split the camera frustum and create the cascades.
  57895. * 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.
  57896. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  57897. */
  57898. get lambda(): number;
  57899. set lambda(value: number);
  57900. /**
  57901. * Gets the view matrix corresponding to a given cascade
  57902. * @param cascadeNum cascade to retrieve the view matrix from
  57903. * @returns the cascade view matrix
  57904. */
  57905. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  57906. /**
  57907. * Gets the projection matrix corresponding to a given cascade
  57908. * @param cascadeNum cascade to retrieve the projection matrix from
  57909. * @returns the cascade projection matrix
  57910. */
  57911. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  57912. /**
  57913. * Gets the transformation matrix corresponding to a given cascade
  57914. * @param cascadeNum cascade to retrieve the transformation matrix from
  57915. * @returns the cascade transformation matrix
  57916. */
  57917. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  57918. private _depthRenderer;
  57919. /**
  57920. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  57921. *
  57922. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  57923. *
  57924. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  57925. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  57926. * @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
  57927. */
  57928. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  57929. private _depthReducer;
  57930. private _autoCalcDepthBounds;
  57931. /**
  57932. * Gets or sets the autoCalcDepthBounds property.
  57933. *
  57934. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  57935. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  57936. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  57937. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  57938. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  57939. */
  57940. get autoCalcDepthBounds(): boolean;
  57941. set autoCalcDepthBounds(value: boolean);
  57942. /**
  57943. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  57944. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  57945. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  57946. * for setting the refresh rate on the renderer yourself!
  57947. */
  57948. get autoCalcDepthBoundsRefreshRate(): number;
  57949. set autoCalcDepthBoundsRefreshRate(value: number);
  57950. /**
  57951. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  57952. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  57953. * you change the camera near/far planes!
  57954. */
  57955. splitFrustum(): void;
  57956. private _splitFrustum;
  57957. private _computeMatrices;
  57958. private _computeFrustumInWorldSpace;
  57959. private _computeCascadeFrustum;
  57960. /**
  57961. * Support test.
  57962. */
  57963. static get IsSupported(): boolean;
  57964. /** @hidden */
  57965. static _SceneComponentInitialization: (scene: Scene) => void;
  57966. /**
  57967. * Creates a Cascaded Shadow Generator object.
  57968. * A ShadowGenerator is the required tool to use the shadows.
  57969. * Each directional light casting shadows needs to use its own ShadowGenerator.
  57970. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  57971. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  57972. * @param light The directional light object generating the shadows.
  57973. * @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.
  57974. */
  57975. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  57976. protected _initializeGenerator(): void;
  57977. protected _createTargetRenderTexture(): void;
  57978. protected _initializeShadowMap(): void;
  57979. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  57980. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  57981. /**
  57982. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  57983. * @param defines Defines of the material we want to update
  57984. * @param lightIndex Index of the light in the enabled light list of the material
  57985. */
  57986. prepareDefines(defines: any, lightIndex: number): void;
  57987. /**
  57988. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  57989. * defined in the generator but impacting the effect).
  57990. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  57991. * @param effect The effect we are binfing the information for
  57992. */
  57993. bindShadowLight(lightIndex: string, effect: Effect): void;
  57994. /**
  57995. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  57996. * (eq to view projection * shadow projection matrices)
  57997. * @returns The transform matrix used to create the shadow map
  57998. */
  57999. getTransformMatrix(): Matrix;
  58000. /**
  58001. * Disposes the ShadowGenerator.
  58002. * Returns nothing.
  58003. */
  58004. dispose(): void;
  58005. /**
  58006. * Serializes the shadow generator setup to a json object.
  58007. * @returns The serialized JSON object
  58008. */
  58009. serialize(): any;
  58010. /**
  58011. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  58012. * @param parsedShadowGenerator The JSON object to parse
  58013. * @param scene The scene to create the shadow map for
  58014. * @returns The parsed shadow generator
  58015. */
  58016. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  58017. }
  58018. }
  58019. declare module BABYLON {
  58020. /**
  58021. * Defines the shadow generator component responsible to manage any shadow generators
  58022. * in a given scene.
  58023. */
  58024. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  58025. /**
  58026. * The component name helpfull to identify the component in the list of scene components.
  58027. */
  58028. readonly name: string;
  58029. /**
  58030. * The scene the component belongs to.
  58031. */
  58032. scene: Scene;
  58033. /**
  58034. * Creates a new instance of the component for the given scene
  58035. * @param scene Defines the scene to register the component in
  58036. */
  58037. constructor(scene: Scene);
  58038. /**
  58039. * Registers the component in a given scene
  58040. */
  58041. register(): void;
  58042. /**
  58043. * Rebuilds the elements related to this component in case of
  58044. * context lost for instance.
  58045. */
  58046. rebuild(): void;
  58047. /**
  58048. * Serializes the component data to the specified json object
  58049. * @param serializationObject The object to serialize to
  58050. */
  58051. serialize(serializationObject: any): void;
  58052. /**
  58053. * Adds all the elements from the container to the scene
  58054. * @param container the container holding the elements
  58055. */
  58056. addFromContainer(container: AbstractScene): void;
  58057. /**
  58058. * Removes all the elements in the container from the scene
  58059. * @param container contains the elements to remove
  58060. * @param dispose if the removed element should be disposed (default: false)
  58061. */
  58062. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58063. /**
  58064. * Rebuilds the elements related to this component in case of
  58065. * context lost for instance.
  58066. */
  58067. dispose(): void;
  58068. private _gatherRenderTargets;
  58069. }
  58070. }
  58071. declare module BABYLON {
  58072. /**
  58073. * A point light is a light defined by an unique point in world space.
  58074. * The light is emitted in every direction from this point.
  58075. * A good example of a point light is a standard light bulb.
  58076. * Documentation: https://doc.babylonjs.com/babylon101/lights
  58077. */
  58078. export class PointLight extends ShadowLight {
  58079. private _shadowAngle;
  58080. /**
  58081. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58082. * This specifies what angle the shadow will use to be created.
  58083. *
  58084. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58085. */
  58086. get shadowAngle(): number;
  58087. /**
  58088. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58089. * This specifies what angle the shadow will use to be created.
  58090. *
  58091. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58092. */
  58093. set shadowAngle(value: number);
  58094. /**
  58095. * Gets the direction if it has been set.
  58096. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58097. */
  58098. get direction(): Vector3;
  58099. /**
  58100. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58101. */
  58102. set direction(value: Vector3);
  58103. /**
  58104. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  58105. * A PointLight emits the light in every direction.
  58106. * It can cast shadows.
  58107. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  58108. * ```javascript
  58109. * var pointLight = new PointLight("pl", camera.position, scene);
  58110. * ```
  58111. * Documentation : https://doc.babylonjs.com/babylon101/lights
  58112. * @param name The light friendly name
  58113. * @param position The position of the point light in the scene
  58114. * @param scene The scene the lights belongs to
  58115. */
  58116. constructor(name: string, position: Vector3, scene: Scene);
  58117. /**
  58118. * Returns the string "PointLight"
  58119. * @returns the class name
  58120. */
  58121. getClassName(): string;
  58122. /**
  58123. * Returns the integer 0.
  58124. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  58125. */
  58126. getTypeID(): number;
  58127. /**
  58128. * Specifies wether or not the shadowmap should be a cube texture.
  58129. * @returns true if the shadowmap needs to be a cube texture.
  58130. */
  58131. needCube(): boolean;
  58132. /**
  58133. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  58134. * @param faceIndex The index of the face we are computed the direction to generate shadow
  58135. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  58136. */
  58137. getShadowDirection(faceIndex?: number): Vector3;
  58138. /**
  58139. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  58140. * - fov = PI / 2
  58141. * - aspect ratio : 1.0
  58142. * - z-near and far equal to the active camera minZ and maxZ.
  58143. * Returns the PointLight.
  58144. */
  58145. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  58146. protected _buildUniformLayout(): void;
  58147. /**
  58148. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  58149. * @param effect The effect to update
  58150. * @param lightIndex The index of the light in the effect to update
  58151. * @returns The point light
  58152. */
  58153. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  58154. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  58155. /**
  58156. * Prepares the list of defines specific to the light type.
  58157. * @param defines the list of defines
  58158. * @param lightIndex defines the index of the light for the effect
  58159. */
  58160. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  58161. }
  58162. }
  58163. declare module BABYLON {
  58164. /**
  58165. * Header information of HDR texture files.
  58166. */
  58167. export interface HDRInfo {
  58168. /**
  58169. * The height of the texture in pixels.
  58170. */
  58171. height: number;
  58172. /**
  58173. * The width of the texture in pixels.
  58174. */
  58175. width: number;
  58176. /**
  58177. * The index of the beginning of the data in the binary file.
  58178. */
  58179. dataPosition: number;
  58180. }
  58181. /**
  58182. * This groups tools to convert HDR texture to native colors array.
  58183. */
  58184. export class HDRTools {
  58185. private static Ldexp;
  58186. private static Rgbe2float;
  58187. private static readStringLine;
  58188. /**
  58189. * Reads header information from an RGBE texture stored in a native array.
  58190. * More information on this format are available here:
  58191. * https://en.wikipedia.org/wiki/RGBE_image_format
  58192. *
  58193. * @param uint8array The binary file stored in native array.
  58194. * @return The header information.
  58195. */
  58196. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  58197. /**
  58198. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  58199. * This RGBE texture needs to store the information as a panorama.
  58200. *
  58201. * More information on this format are available here:
  58202. * https://en.wikipedia.org/wiki/RGBE_image_format
  58203. *
  58204. * @param buffer The binary file stored in an array buffer.
  58205. * @param size The expected size of the extracted cubemap.
  58206. * @return The Cube Map information.
  58207. */
  58208. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  58209. /**
  58210. * Returns the pixels data extracted from an RGBE texture.
  58211. * This pixels will be stored left to right up to down in the R G B order in one array.
  58212. *
  58213. * More information on this format are available here:
  58214. * https://en.wikipedia.org/wiki/RGBE_image_format
  58215. *
  58216. * @param uint8array The binary file stored in an array buffer.
  58217. * @param hdrInfo The header information of the file.
  58218. * @return The pixels data in RGB right to left up to down order.
  58219. */
  58220. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  58221. private static RGBE_ReadPixels_RLE;
  58222. }
  58223. }
  58224. declare module BABYLON {
  58225. /**
  58226. * Effect Render Options
  58227. */
  58228. export interface IEffectRendererOptions {
  58229. /**
  58230. * Defines the vertices positions.
  58231. */
  58232. positions?: number[];
  58233. /**
  58234. * Defines the indices.
  58235. */
  58236. indices?: number[];
  58237. }
  58238. /**
  58239. * Helper class to render one or more effects.
  58240. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  58241. */
  58242. export class EffectRenderer {
  58243. private engine;
  58244. private static _DefaultOptions;
  58245. private _vertexBuffers;
  58246. private _indexBuffer;
  58247. private _fullscreenViewport;
  58248. /**
  58249. * Creates an effect renderer
  58250. * @param engine the engine to use for rendering
  58251. * @param options defines the options of the effect renderer
  58252. */
  58253. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  58254. /**
  58255. * Sets the current viewport in normalized coordinates 0-1
  58256. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58257. */
  58258. setViewport(viewport?: Viewport): void;
  58259. /**
  58260. * Binds the embedded attributes buffer to the effect.
  58261. * @param effect Defines the effect to bind the attributes for
  58262. */
  58263. bindBuffers(effect: Effect): void;
  58264. /**
  58265. * Sets the current effect wrapper to use during draw.
  58266. * The effect needs to be ready before calling this api.
  58267. * This also sets the default full screen position attribute.
  58268. * @param effectWrapper Defines the effect to draw with
  58269. */
  58270. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58271. /**
  58272. * Restores engine states
  58273. */
  58274. restoreStates(): void;
  58275. /**
  58276. * Draws a full screen quad.
  58277. */
  58278. draw(): void;
  58279. private isRenderTargetTexture;
  58280. /**
  58281. * renders one or more effects to a specified texture
  58282. * @param effectWrapper the effect to renderer
  58283. * @param outputTexture texture to draw to, if null it will render to the screen.
  58284. */
  58285. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  58286. /**
  58287. * Disposes of the effect renderer
  58288. */
  58289. dispose(): void;
  58290. }
  58291. /**
  58292. * Options to create an EffectWrapper
  58293. */
  58294. interface EffectWrapperCreationOptions {
  58295. /**
  58296. * Engine to use to create the effect
  58297. */
  58298. engine: ThinEngine;
  58299. /**
  58300. * Fragment shader for the effect
  58301. */
  58302. fragmentShader: string;
  58303. /**
  58304. * Use the shader store instead of direct source code
  58305. */
  58306. useShaderStore?: boolean;
  58307. /**
  58308. * Vertex shader for the effect
  58309. */
  58310. vertexShader?: string;
  58311. /**
  58312. * Attributes to use in the shader
  58313. */
  58314. attributeNames?: Array<string>;
  58315. /**
  58316. * Uniforms to use in the shader
  58317. */
  58318. uniformNames?: Array<string>;
  58319. /**
  58320. * Texture sampler names to use in the shader
  58321. */
  58322. samplerNames?: Array<string>;
  58323. /**
  58324. * Defines to use in the shader
  58325. */
  58326. defines?: Array<string>;
  58327. /**
  58328. * Callback when effect is compiled
  58329. */
  58330. onCompiled?: Nullable<(effect: Effect) => void>;
  58331. /**
  58332. * The friendly name of the effect displayed in Spector.
  58333. */
  58334. name?: string;
  58335. }
  58336. /**
  58337. * Wraps an effect to be used for rendering
  58338. */
  58339. export class EffectWrapper {
  58340. /**
  58341. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58342. */
  58343. onApplyObservable: Observable<{}>;
  58344. /**
  58345. * The underlying effect
  58346. */
  58347. effect: Effect;
  58348. /**
  58349. * Creates an effect to be renderer
  58350. * @param creationOptions options to create the effect
  58351. */
  58352. constructor(creationOptions: EffectWrapperCreationOptions);
  58353. /**
  58354. * Disposes of the effect wrapper
  58355. */
  58356. dispose(): void;
  58357. }
  58358. }
  58359. declare module BABYLON {
  58360. /** @hidden */
  58361. export var hdrFilteringVertexShader: {
  58362. name: string;
  58363. shader: string;
  58364. };
  58365. }
  58366. declare module BABYLON {
  58367. /** @hidden */
  58368. export var hdrFilteringPixelShader: {
  58369. name: string;
  58370. shader: string;
  58371. };
  58372. }
  58373. declare module BABYLON {
  58374. /**
  58375. * Options for texture filtering
  58376. */
  58377. interface IHDRFilteringOptions {
  58378. /**
  58379. * Scales pixel intensity for the input HDR map.
  58380. */
  58381. hdrScale?: number;
  58382. /**
  58383. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  58384. */
  58385. quality?: number;
  58386. }
  58387. /**
  58388. * Filters HDR maps to get correct renderings of PBR reflections
  58389. */
  58390. export class HDRFiltering {
  58391. private _engine;
  58392. private _effectRenderer;
  58393. private _effectWrapper;
  58394. private _lodGenerationOffset;
  58395. private _lodGenerationScale;
  58396. /**
  58397. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  58398. * you care about baking speed.
  58399. */
  58400. quality: number;
  58401. /**
  58402. * Scales pixel intensity for the input HDR map.
  58403. */
  58404. hdrScale: number;
  58405. /**
  58406. * Instantiates HDR filter for reflection maps
  58407. *
  58408. * @param engine Thin engine
  58409. * @param options Options
  58410. */
  58411. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  58412. private _createRenderTarget;
  58413. private _prefilterInternal;
  58414. private _createEffect;
  58415. /**
  58416. * Get a value indicating if the filter is ready to be used
  58417. * @param texture Texture to filter
  58418. * @returns true if the filter is ready
  58419. */
  58420. isReady(texture: BaseTexture): boolean;
  58421. /**
  58422. * Prefilters a cube texture to have mipmap levels representing roughness values.
  58423. * Prefiltering will be invoked at the end of next rendering pass.
  58424. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  58425. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  58426. * @param texture Texture to filter
  58427. * @param onFinished Callback when filtering is done
  58428. * @return Promise called when prefiltering is done
  58429. */
  58430. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown>;
  58431. }
  58432. }
  58433. declare module BABYLON {
  58434. /**
  58435. * This represents a texture coming from an HDR input.
  58436. *
  58437. * The only supported format is currently panorama picture stored in RGBE format.
  58438. * Example of such files can be found on HDRLib: http://hdrlib.com/
  58439. */
  58440. export class HDRCubeTexture extends BaseTexture {
  58441. private static _facesMapping;
  58442. private _generateHarmonics;
  58443. private _noMipmap;
  58444. private _prefilterOnLoad;
  58445. private _textureMatrix;
  58446. private _size;
  58447. private _onLoad;
  58448. private _onError;
  58449. /**
  58450. * The texture URL.
  58451. */
  58452. url: string;
  58453. /**
  58454. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  58455. */
  58456. coordinatesMode: number;
  58457. protected _isBlocking: boolean;
  58458. /**
  58459. * Sets wether or not the texture is blocking during loading.
  58460. */
  58461. set isBlocking(value: boolean);
  58462. /**
  58463. * Gets wether or not the texture is blocking during loading.
  58464. */
  58465. get isBlocking(): boolean;
  58466. protected _rotationY: number;
  58467. /**
  58468. * Sets texture matrix rotation angle around Y axis in radians.
  58469. */
  58470. set rotationY(value: number);
  58471. /**
  58472. * Gets texture matrix rotation angle around Y axis radians.
  58473. */
  58474. get rotationY(): number;
  58475. /**
  58476. * Gets or sets the center of the bounding box associated with the cube texture
  58477. * It must define where the camera used to render the texture was set
  58478. */
  58479. boundingBoxPosition: Vector3;
  58480. private _boundingBoxSize;
  58481. /**
  58482. * Gets or sets the size of the bounding box associated with the cube texture
  58483. * When defined, the cubemap will switch to local mode
  58484. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  58485. * @example https://www.babylonjs-playground.com/#RNASML
  58486. */
  58487. set boundingBoxSize(value: Vector3);
  58488. get boundingBoxSize(): Vector3;
  58489. /**
  58490. * Instantiates an HDRTexture from the following parameters.
  58491. *
  58492. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  58493. * @param sceneOrEngine The scene or engine the texture will be used in
  58494. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58495. * @param noMipmap Forces to not generate the mipmap if true
  58496. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  58497. * @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)
  58498. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  58499. */
  58500. 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>);
  58501. /**
  58502. * Get the current class name of the texture useful for serialization or dynamic coding.
  58503. * @returns "HDRCubeTexture"
  58504. */
  58505. getClassName(): string;
  58506. /**
  58507. * Occurs when the file is raw .hdr file.
  58508. */
  58509. private loadTexture;
  58510. clone(): HDRCubeTexture;
  58511. delayLoad(): void;
  58512. /**
  58513. * Get the texture reflection matrix used to rotate/transform the reflection.
  58514. * @returns the reflection matrix
  58515. */
  58516. getReflectionTextureMatrix(): Matrix;
  58517. /**
  58518. * Set the texture reflection matrix used to rotate/transform the reflection.
  58519. * @param value Define the reflection matrix to set
  58520. */
  58521. setReflectionTextureMatrix(value: Matrix): void;
  58522. /**
  58523. * Parses a JSON representation of an HDR Texture in order to create the texture
  58524. * @param parsedTexture Define the JSON representation
  58525. * @param scene Define the scene the texture should be created in
  58526. * @param rootUrl Define the root url in case we need to load relative dependencies
  58527. * @returns the newly created texture after parsing
  58528. */
  58529. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  58530. serialize(): any;
  58531. }
  58532. }
  58533. declare module BABYLON {
  58534. /**
  58535. * Class used to control physics engine
  58536. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  58537. */
  58538. export class PhysicsEngine implements IPhysicsEngine {
  58539. private _physicsPlugin;
  58540. /**
  58541. * Global value used to control the smallest number supported by the simulation
  58542. */
  58543. static Epsilon: number;
  58544. private _impostors;
  58545. private _joints;
  58546. private _subTimeStep;
  58547. /**
  58548. * Gets the gravity vector used by the simulation
  58549. */
  58550. gravity: Vector3;
  58551. /**
  58552. * Factory used to create the default physics plugin.
  58553. * @returns The default physics plugin
  58554. */
  58555. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  58556. /**
  58557. * Creates a new Physics Engine
  58558. * @param gravity defines the gravity vector used by the simulation
  58559. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  58560. */
  58561. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  58562. /**
  58563. * Sets the gravity vector used by the simulation
  58564. * @param gravity defines the gravity vector to use
  58565. */
  58566. setGravity(gravity: Vector3): void;
  58567. /**
  58568. * Set the time step of the physics engine.
  58569. * Default is 1/60.
  58570. * To slow it down, enter 1/600 for example.
  58571. * To speed it up, 1/30
  58572. * @param newTimeStep defines the new timestep to apply to this world.
  58573. */
  58574. setTimeStep(newTimeStep?: number): void;
  58575. /**
  58576. * Get the time step of the physics engine.
  58577. * @returns the current time step
  58578. */
  58579. getTimeStep(): number;
  58580. /**
  58581. * Set the sub time step of the physics engine.
  58582. * Default is 0 meaning there is no sub steps
  58583. * To increase physics resolution precision, set a small value (like 1 ms)
  58584. * @param subTimeStep defines the new sub timestep used for physics resolution.
  58585. */
  58586. setSubTimeStep(subTimeStep?: number): void;
  58587. /**
  58588. * Get the sub time step of the physics engine.
  58589. * @returns the current sub time step
  58590. */
  58591. getSubTimeStep(): number;
  58592. /**
  58593. * Release all resources
  58594. */
  58595. dispose(): void;
  58596. /**
  58597. * Gets the name of the current physics plugin
  58598. * @returns the name of the plugin
  58599. */
  58600. getPhysicsPluginName(): string;
  58601. /**
  58602. * Adding a new impostor for the impostor tracking.
  58603. * This will be done by the impostor itself.
  58604. * @param impostor the impostor to add
  58605. */
  58606. addImpostor(impostor: PhysicsImpostor): void;
  58607. /**
  58608. * Remove an impostor from the engine.
  58609. * This impostor and its mesh will not longer be updated by the physics engine.
  58610. * @param impostor the impostor to remove
  58611. */
  58612. removeImpostor(impostor: PhysicsImpostor): void;
  58613. /**
  58614. * Add a joint to the physics engine
  58615. * @param mainImpostor defines the main impostor to which the joint is added.
  58616. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  58617. * @param joint defines the joint that will connect both impostors.
  58618. */
  58619. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  58620. /**
  58621. * Removes a joint from the simulation
  58622. * @param mainImpostor defines the impostor used with the joint
  58623. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  58624. * @param joint defines the joint to remove
  58625. */
  58626. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  58627. /**
  58628. * Called by the scene. No need to call it.
  58629. * @param delta defines the timespam between frames
  58630. */
  58631. _step(delta: number): void;
  58632. /**
  58633. * Gets the current plugin used to run the simulation
  58634. * @returns current plugin
  58635. */
  58636. getPhysicsPlugin(): IPhysicsEnginePlugin;
  58637. /**
  58638. * Gets the list of physic impostors
  58639. * @returns an array of PhysicsImpostor
  58640. */
  58641. getImpostors(): Array<PhysicsImpostor>;
  58642. /**
  58643. * Gets the impostor for a physics enabled object
  58644. * @param object defines the object impersonated by the impostor
  58645. * @returns the PhysicsImpostor or null if not found
  58646. */
  58647. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  58648. /**
  58649. * Gets the impostor for a physics body object
  58650. * @param body defines physics body used by the impostor
  58651. * @returns the PhysicsImpostor or null if not found
  58652. */
  58653. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  58654. /**
  58655. * Does a raycast in the physics world
  58656. * @param from when should the ray start?
  58657. * @param to when should the ray end?
  58658. * @returns PhysicsRaycastResult
  58659. */
  58660. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58661. }
  58662. }
  58663. declare module BABYLON {
  58664. /** @hidden */
  58665. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  58666. private _useDeltaForWorldStep;
  58667. world: any;
  58668. name: string;
  58669. private _physicsMaterials;
  58670. private _fixedTimeStep;
  58671. private _cannonRaycastResult;
  58672. private _raycastResult;
  58673. private _physicsBodysToRemoveAfterStep;
  58674. BJSCANNON: any;
  58675. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  58676. setGravity(gravity: Vector3): void;
  58677. setTimeStep(timeStep: number): void;
  58678. getTimeStep(): number;
  58679. executeStep(delta: number): void;
  58680. private _removeMarkedPhysicsBodiesFromWorld;
  58681. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58682. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58683. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58684. private _processChildMeshes;
  58685. removePhysicsBody(impostor: PhysicsImpostor): void;
  58686. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58687. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58688. private _addMaterial;
  58689. private _checkWithEpsilon;
  58690. private _createShape;
  58691. private _createHeightmap;
  58692. private _minus90X;
  58693. private _plus90X;
  58694. private _tmpPosition;
  58695. private _tmpDeltaPosition;
  58696. private _tmpUnityRotation;
  58697. private _updatePhysicsBodyTransformation;
  58698. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58699. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58700. isSupported(): boolean;
  58701. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58702. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58703. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58704. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58705. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58706. getBodyMass(impostor: PhysicsImpostor): number;
  58707. getBodyFriction(impostor: PhysicsImpostor): number;
  58708. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58709. getBodyRestitution(impostor: PhysicsImpostor): number;
  58710. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58711. sleepBody(impostor: PhysicsImpostor): void;
  58712. wakeUpBody(impostor: PhysicsImpostor): void;
  58713. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  58714. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  58715. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  58716. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58717. getRadius(impostor: PhysicsImpostor): number;
  58718. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58719. dispose(): void;
  58720. private _extendNamespace;
  58721. /**
  58722. * Does a raycast in the physics world
  58723. * @param from when should the ray start?
  58724. * @param to when should the ray end?
  58725. * @returns PhysicsRaycastResult
  58726. */
  58727. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58728. }
  58729. }
  58730. declare module BABYLON {
  58731. /** @hidden */
  58732. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  58733. private _useDeltaForWorldStep;
  58734. world: any;
  58735. name: string;
  58736. BJSOIMO: any;
  58737. private _raycastResult;
  58738. private _fixedTimeStep;
  58739. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  58740. setGravity(gravity: Vector3): void;
  58741. setTimeStep(timeStep: number): void;
  58742. getTimeStep(): number;
  58743. private _tmpImpostorsArray;
  58744. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  58745. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58746. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58747. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58748. private _tmpPositionVector;
  58749. removePhysicsBody(impostor: PhysicsImpostor): void;
  58750. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58751. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58752. isSupported(): boolean;
  58753. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58754. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58755. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58756. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58757. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58758. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58759. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58760. getBodyMass(impostor: PhysicsImpostor): number;
  58761. getBodyFriction(impostor: PhysicsImpostor): number;
  58762. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58763. getBodyRestitution(impostor: PhysicsImpostor): number;
  58764. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58765. sleepBody(impostor: PhysicsImpostor): void;
  58766. wakeUpBody(impostor: PhysicsImpostor): void;
  58767. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  58768. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  58769. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  58770. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58771. getRadius(impostor: PhysicsImpostor): number;
  58772. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58773. dispose(): void;
  58774. /**
  58775. * Does a raycast in the physics world
  58776. * @param from when should the ray start?
  58777. * @param to when should the ray end?
  58778. * @returns PhysicsRaycastResult
  58779. */
  58780. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58781. }
  58782. }
  58783. declare module BABYLON {
  58784. /**
  58785. * Class containing static functions to help procedurally build meshes
  58786. */
  58787. export class RibbonBuilder {
  58788. /**
  58789. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58790. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58791. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58792. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58793. * * 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
  58794. * * 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
  58795. * * 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
  58796. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58797. * * 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
  58798. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58799. * * 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
  58800. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58801. * * 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
  58802. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58803. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58804. * @param name defines the name of the mesh
  58805. * @param options defines the options used to create the mesh
  58806. * @param scene defines the hosting scene
  58807. * @returns the ribbon mesh
  58808. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58809. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58810. */
  58811. static CreateRibbon(name: string, options: {
  58812. pathArray: Vector3[][];
  58813. closeArray?: boolean;
  58814. closePath?: boolean;
  58815. offset?: number;
  58816. updatable?: boolean;
  58817. sideOrientation?: number;
  58818. frontUVs?: Vector4;
  58819. backUVs?: Vector4;
  58820. instance?: Mesh;
  58821. invertUV?: boolean;
  58822. uvs?: Vector2[];
  58823. colors?: Color4[];
  58824. }, scene?: Nullable<Scene>): Mesh;
  58825. }
  58826. }
  58827. declare module BABYLON {
  58828. /**
  58829. * Class containing static functions to help procedurally build meshes
  58830. */
  58831. export class ShapeBuilder {
  58832. /**
  58833. * 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.
  58834. * * 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.
  58835. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58836. * * 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.
  58837. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58838. * * 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
  58839. * * 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
  58840. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58841. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58842. * * 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
  58843. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58844. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58845. * @param name defines the name of the mesh
  58846. * @param options defines the options used to create the mesh
  58847. * @param scene defines the hosting scene
  58848. * @returns the extruded shape mesh
  58849. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58850. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58851. */
  58852. static ExtrudeShape(name: string, options: {
  58853. shape: Vector3[];
  58854. path: Vector3[];
  58855. scale?: number;
  58856. rotation?: number;
  58857. cap?: number;
  58858. updatable?: boolean;
  58859. sideOrientation?: number;
  58860. frontUVs?: Vector4;
  58861. backUVs?: Vector4;
  58862. instance?: Mesh;
  58863. invertUV?: boolean;
  58864. }, scene?: Nullable<Scene>): Mesh;
  58865. /**
  58866. * Creates an custom extruded shape mesh.
  58867. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58868. * * 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.
  58869. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58870. * * 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
  58871. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58872. * * 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
  58873. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58874. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58875. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58876. * * 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
  58877. * * 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
  58878. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  58879. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58880. * * 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
  58881. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58882. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58883. * @param name defines the name of the mesh
  58884. * @param options defines the options used to create the mesh
  58885. * @param scene defines the hosting scene
  58886. * @returns the custom extruded shape mesh
  58887. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58888. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58889. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58890. */
  58891. static ExtrudeShapeCustom(name: string, options: {
  58892. shape: Vector3[];
  58893. path: Vector3[];
  58894. scaleFunction?: any;
  58895. rotationFunction?: any;
  58896. ribbonCloseArray?: boolean;
  58897. ribbonClosePath?: boolean;
  58898. cap?: number;
  58899. updatable?: boolean;
  58900. sideOrientation?: number;
  58901. frontUVs?: Vector4;
  58902. backUVs?: Vector4;
  58903. instance?: Mesh;
  58904. invertUV?: boolean;
  58905. }, scene?: Nullable<Scene>): Mesh;
  58906. private static _ExtrudeShapeGeneric;
  58907. }
  58908. }
  58909. declare module BABYLON {
  58910. /**
  58911. * AmmoJS Physics plugin
  58912. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  58913. * @see https://github.com/kripken/ammo.js/
  58914. */
  58915. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  58916. private _useDeltaForWorldStep;
  58917. /**
  58918. * Reference to the Ammo library
  58919. */
  58920. bjsAMMO: any;
  58921. /**
  58922. * Created ammoJS world which physics bodies are added to
  58923. */
  58924. world: any;
  58925. /**
  58926. * Name of the plugin
  58927. */
  58928. name: string;
  58929. private _timeStep;
  58930. private _fixedTimeStep;
  58931. private _maxSteps;
  58932. private _tmpQuaternion;
  58933. private _tmpAmmoTransform;
  58934. private _tmpAmmoQuaternion;
  58935. private _tmpAmmoConcreteContactResultCallback;
  58936. private _collisionConfiguration;
  58937. private _dispatcher;
  58938. private _overlappingPairCache;
  58939. private _solver;
  58940. private _softBodySolver;
  58941. private _tmpAmmoVectorA;
  58942. private _tmpAmmoVectorB;
  58943. private _tmpAmmoVectorC;
  58944. private _tmpAmmoVectorD;
  58945. private _tmpContactCallbackResult;
  58946. private _tmpAmmoVectorRCA;
  58947. private _tmpAmmoVectorRCB;
  58948. private _raycastResult;
  58949. private static readonly DISABLE_COLLISION_FLAG;
  58950. private static readonly KINEMATIC_FLAG;
  58951. private static readonly DISABLE_DEACTIVATION_FLAG;
  58952. /**
  58953. * Initializes the ammoJS plugin
  58954. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  58955. * @param ammoInjection can be used to inject your own ammo reference
  58956. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  58957. */
  58958. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  58959. /**
  58960. * Sets the gravity of the physics world (m/(s^2))
  58961. * @param gravity Gravity to set
  58962. */
  58963. setGravity(gravity: Vector3): void;
  58964. /**
  58965. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  58966. * @param timeStep timestep to use in seconds
  58967. */
  58968. setTimeStep(timeStep: number): void;
  58969. /**
  58970. * 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)
  58971. * @param fixedTimeStep fixedTimeStep to use in seconds
  58972. */
  58973. setFixedTimeStep(fixedTimeStep: number): void;
  58974. /**
  58975. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  58976. * @param maxSteps the maximum number of steps by the physics engine per frame
  58977. */
  58978. setMaxSteps(maxSteps: number): void;
  58979. /**
  58980. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  58981. * @returns the current timestep in seconds
  58982. */
  58983. getTimeStep(): number;
  58984. /**
  58985. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  58986. */
  58987. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  58988. private _isImpostorInContact;
  58989. private _isImpostorPairInContact;
  58990. private _stepSimulation;
  58991. /**
  58992. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  58993. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  58994. * After the step the babylon meshes are set to the position of the physics imposters
  58995. * @param delta amount of time to step forward
  58996. * @param impostors array of imposters to update before/after the step
  58997. */
  58998. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  58999. /**
  59000. * Update babylon mesh to match physics world object
  59001. * @param impostor imposter to match
  59002. */
  59003. private _afterSoftStep;
  59004. /**
  59005. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59006. * @param impostor imposter to match
  59007. */
  59008. private _ropeStep;
  59009. /**
  59010. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59011. * @param impostor imposter to match
  59012. */
  59013. private _softbodyOrClothStep;
  59014. private _tmpMatrix;
  59015. /**
  59016. * Applies an impulse on the imposter
  59017. * @param impostor imposter to apply impulse to
  59018. * @param force amount of force to be applied to the imposter
  59019. * @param contactPoint the location to apply the impulse on the imposter
  59020. */
  59021. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59022. /**
  59023. * Applies a force on the imposter
  59024. * @param impostor imposter to apply force
  59025. * @param force amount of force to be applied to the imposter
  59026. * @param contactPoint the location to apply the force on the imposter
  59027. */
  59028. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59029. /**
  59030. * Creates a physics body using the plugin
  59031. * @param impostor the imposter to create the physics body on
  59032. */
  59033. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59034. /**
  59035. * Removes the physics body from the imposter and disposes of the body's memory
  59036. * @param impostor imposter to remove the physics body from
  59037. */
  59038. removePhysicsBody(impostor: PhysicsImpostor): void;
  59039. /**
  59040. * Generates a joint
  59041. * @param impostorJoint the imposter joint to create the joint with
  59042. */
  59043. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59044. /**
  59045. * Removes a joint
  59046. * @param impostorJoint the imposter joint to remove the joint from
  59047. */
  59048. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59049. private _addMeshVerts;
  59050. /**
  59051. * Initialise the soft body vertices to match its object's (mesh) vertices
  59052. * Softbody vertices (nodes) are in world space and to match this
  59053. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  59054. * @param impostor to create the softbody for
  59055. */
  59056. private _softVertexData;
  59057. /**
  59058. * Create an impostor's soft body
  59059. * @param impostor to create the softbody for
  59060. */
  59061. private _createSoftbody;
  59062. /**
  59063. * Create cloth for an impostor
  59064. * @param impostor to create the softbody for
  59065. */
  59066. private _createCloth;
  59067. /**
  59068. * Create rope for an impostor
  59069. * @param impostor to create the softbody for
  59070. */
  59071. private _createRope;
  59072. /**
  59073. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  59074. * @param impostor to create the custom physics shape for
  59075. */
  59076. private _createCustom;
  59077. private _addHullVerts;
  59078. private _createShape;
  59079. /**
  59080. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  59081. * @param impostor imposter containing the physics body and babylon object
  59082. */
  59083. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59084. /**
  59085. * Sets the babylon object's position/rotation from the physics body's position/rotation
  59086. * @param impostor imposter containing the physics body and babylon object
  59087. * @param newPosition new position
  59088. * @param newRotation new rotation
  59089. */
  59090. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59091. /**
  59092. * If this plugin is supported
  59093. * @returns true if its supported
  59094. */
  59095. isSupported(): boolean;
  59096. /**
  59097. * Sets the linear velocity of the physics body
  59098. * @param impostor imposter to set the velocity on
  59099. * @param velocity velocity to set
  59100. */
  59101. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59102. /**
  59103. * Sets the angular velocity of the physics body
  59104. * @param impostor imposter to set the velocity on
  59105. * @param velocity velocity to set
  59106. */
  59107. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59108. /**
  59109. * gets the linear velocity
  59110. * @param impostor imposter to get linear velocity from
  59111. * @returns linear velocity
  59112. */
  59113. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59114. /**
  59115. * gets the angular velocity
  59116. * @param impostor imposter to get angular velocity from
  59117. * @returns angular velocity
  59118. */
  59119. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59120. /**
  59121. * Sets the mass of physics body
  59122. * @param impostor imposter to set the mass on
  59123. * @param mass mass to set
  59124. */
  59125. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59126. /**
  59127. * Gets the mass of the physics body
  59128. * @param impostor imposter to get the mass from
  59129. * @returns mass
  59130. */
  59131. getBodyMass(impostor: PhysicsImpostor): number;
  59132. /**
  59133. * Gets friction of the impostor
  59134. * @param impostor impostor to get friction from
  59135. * @returns friction value
  59136. */
  59137. getBodyFriction(impostor: PhysicsImpostor): number;
  59138. /**
  59139. * Sets friction of the impostor
  59140. * @param impostor impostor to set friction on
  59141. * @param friction friction value
  59142. */
  59143. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59144. /**
  59145. * Gets restitution of the impostor
  59146. * @param impostor impostor to get restitution from
  59147. * @returns restitution value
  59148. */
  59149. getBodyRestitution(impostor: PhysicsImpostor): number;
  59150. /**
  59151. * Sets resitution of the impostor
  59152. * @param impostor impostor to set resitution on
  59153. * @param restitution resitution value
  59154. */
  59155. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59156. /**
  59157. * Gets pressure inside the impostor
  59158. * @param impostor impostor to get pressure from
  59159. * @returns pressure value
  59160. */
  59161. getBodyPressure(impostor: PhysicsImpostor): number;
  59162. /**
  59163. * Sets pressure inside a soft body impostor
  59164. * Cloth and rope must remain 0 pressure
  59165. * @param impostor impostor to set pressure on
  59166. * @param pressure pressure value
  59167. */
  59168. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  59169. /**
  59170. * Gets stiffness of the impostor
  59171. * @param impostor impostor to get stiffness from
  59172. * @returns pressure value
  59173. */
  59174. getBodyStiffness(impostor: PhysicsImpostor): number;
  59175. /**
  59176. * Sets stiffness of the impostor
  59177. * @param impostor impostor to set stiffness on
  59178. * @param stiffness stiffness value from 0 to 1
  59179. */
  59180. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  59181. /**
  59182. * Gets velocityIterations of the impostor
  59183. * @param impostor impostor to get velocity iterations from
  59184. * @returns velocityIterations value
  59185. */
  59186. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  59187. /**
  59188. * Sets velocityIterations of the impostor
  59189. * @param impostor impostor to set velocity iterations on
  59190. * @param velocityIterations velocityIterations value
  59191. */
  59192. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  59193. /**
  59194. * Gets positionIterations of the impostor
  59195. * @param impostor impostor to get position iterations from
  59196. * @returns positionIterations value
  59197. */
  59198. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  59199. /**
  59200. * Sets positionIterations of the impostor
  59201. * @param impostor impostor to set position on
  59202. * @param positionIterations positionIterations value
  59203. */
  59204. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  59205. /**
  59206. * Append an anchor to a cloth object
  59207. * @param impostor is the cloth impostor to add anchor to
  59208. * @param otherImpostor is the rigid impostor to anchor to
  59209. * @param width ratio across width from 0 to 1
  59210. * @param height ratio up height from 0 to 1
  59211. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  59212. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  59213. */
  59214. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  59215. /**
  59216. * Append an hook to a rope object
  59217. * @param impostor is the rope impostor to add hook to
  59218. * @param otherImpostor is the rigid impostor to hook to
  59219. * @param length ratio along the rope from 0 to 1
  59220. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  59221. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  59222. */
  59223. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  59224. /**
  59225. * Sleeps the physics body and stops it from being active
  59226. * @param impostor impostor to sleep
  59227. */
  59228. sleepBody(impostor: PhysicsImpostor): void;
  59229. /**
  59230. * Activates the physics body
  59231. * @param impostor impostor to activate
  59232. */
  59233. wakeUpBody(impostor: PhysicsImpostor): void;
  59234. /**
  59235. * Updates the distance parameters of the joint
  59236. * @param joint joint to update
  59237. * @param maxDistance maximum distance of the joint
  59238. * @param minDistance minimum distance of the joint
  59239. */
  59240. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  59241. /**
  59242. * Sets a motor on the joint
  59243. * @param joint joint to set motor on
  59244. * @param speed speed of the motor
  59245. * @param maxForce maximum force of the motor
  59246. * @param motorIndex index of the motor
  59247. */
  59248. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  59249. /**
  59250. * Sets the motors limit
  59251. * @param joint joint to set limit on
  59252. * @param upperLimit upper limit
  59253. * @param lowerLimit lower limit
  59254. */
  59255. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  59256. /**
  59257. * Syncs the position and rotation of a mesh with the impostor
  59258. * @param mesh mesh to sync
  59259. * @param impostor impostor to update the mesh with
  59260. */
  59261. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59262. /**
  59263. * Gets the radius of the impostor
  59264. * @param impostor impostor to get radius from
  59265. * @returns the radius
  59266. */
  59267. getRadius(impostor: PhysicsImpostor): number;
  59268. /**
  59269. * Gets the box size of the impostor
  59270. * @param impostor impostor to get box size from
  59271. * @param result the resulting box size
  59272. */
  59273. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59274. /**
  59275. * Disposes of the impostor
  59276. */
  59277. dispose(): void;
  59278. /**
  59279. * Does a raycast in the physics world
  59280. * @param from when should the ray start?
  59281. * @param to when should the ray end?
  59282. * @returns PhysicsRaycastResult
  59283. */
  59284. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59285. }
  59286. }
  59287. declare module BABYLON {
  59288. interface AbstractScene {
  59289. /**
  59290. * The list of reflection probes added to the scene
  59291. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  59292. */
  59293. reflectionProbes: Array<ReflectionProbe>;
  59294. /**
  59295. * Removes the given reflection probe from this scene.
  59296. * @param toRemove The reflection probe to remove
  59297. * @returns The index of the removed reflection probe
  59298. */
  59299. removeReflectionProbe(toRemove: ReflectionProbe): number;
  59300. /**
  59301. * Adds the given reflection probe to this scene.
  59302. * @param newReflectionProbe The reflection probe to add
  59303. */
  59304. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  59305. }
  59306. /**
  59307. * Class used to generate realtime reflection / refraction cube textures
  59308. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  59309. */
  59310. export class ReflectionProbe {
  59311. /** defines the name of the probe */
  59312. name: string;
  59313. private _scene;
  59314. private _renderTargetTexture;
  59315. private _projectionMatrix;
  59316. private _viewMatrix;
  59317. private _target;
  59318. private _add;
  59319. private _attachedMesh;
  59320. private _invertYAxis;
  59321. /** Gets or sets probe position (center of the cube map) */
  59322. position: Vector3;
  59323. /**
  59324. * Creates a new reflection probe
  59325. * @param name defines the name of the probe
  59326. * @param size defines the texture resolution (for each face)
  59327. * @param scene defines the hosting scene
  59328. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  59329. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  59330. */
  59331. constructor(
  59332. /** defines the name of the probe */
  59333. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  59334. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  59335. get samples(): number;
  59336. set samples(value: number);
  59337. /** Gets or sets the refresh rate to use (on every frame by default) */
  59338. get refreshRate(): number;
  59339. set refreshRate(value: number);
  59340. /**
  59341. * Gets the hosting scene
  59342. * @returns a Scene
  59343. */
  59344. getScene(): Scene;
  59345. /** Gets the internal CubeTexture used to render to */
  59346. get cubeTexture(): RenderTargetTexture;
  59347. /** Gets the list of meshes to render */
  59348. get renderList(): Nullable<AbstractMesh[]>;
  59349. /**
  59350. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  59351. * @param mesh defines the mesh to attach to
  59352. */
  59353. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  59354. /**
  59355. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  59356. * @param renderingGroupId The rendering group id corresponding to its index
  59357. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  59358. */
  59359. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  59360. /**
  59361. * Clean all associated resources
  59362. */
  59363. dispose(): void;
  59364. /**
  59365. * Converts the reflection probe information to a readable string for debug purpose.
  59366. * @param fullDetails Supports for multiple levels of logging within scene loading
  59367. * @returns the human readable reflection probe info
  59368. */
  59369. toString(fullDetails?: boolean): string;
  59370. /**
  59371. * Get the class name of the relfection probe.
  59372. * @returns "ReflectionProbe"
  59373. */
  59374. getClassName(): string;
  59375. /**
  59376. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  59377. * @returns The JSON representation of the texture
  59378. */
  59379. serialize(): any;
  59380. /**
  59381. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  59382. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  59383. * @param scene Define the scene the parsed reflection probe should be instantiated in
  59384. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  59385. * @returns The parsed reflection probe if successful
  59386. */
  59387. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  59388. }
  59389. }
  59390. declare module BABYLON {
  59391. /** @hidden */
  59392. export var _BabylonLoaderRegistered: boolean;
  59393. /**
  59394. * Helps setting up some configuration for the babylon file loader.
  59395. */
  59396. export class BabylonFileLoaderConfiguration {
  59397. /**
  59398. * The loader does not allow injecting custom physix engine into the plugins.
  59399. * Unfortunately in ES6, we need to manually inject them into the plugin.
  59400. * So you could set this variable to your engine import to make it work.
  59401. */
  59402. static LoaderInjectedPhysicsEngine: any;
  59403. }
  59404. }
  59405. declare module BABYLON {
  59406. /**
  59407. * The Physically based simple base material of BJS.
  59408. *
  59409. * This enables better naming and convention enforcements on top of the pbrMaterial.
  59410. * It is used as the base class for both the specGloss and metalRough conventions.
  59411. */
  59412. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  59413. /**
  59414. * Number of Simultaneous lights allowed on the material.
  59415. */
  59416. maxSimultaneousLights: number;
  59417. /**
  59418. * If sets to true, disables all the lights affecting the material.
  59419. */
  59420. disableLighting: boolean;
  59421. /**
  59422. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  59423. */
  59424. environmentTexture: BaseTexture;
  59425. /**
  59426. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  59427. */
  59428. invertNormalMapX: boolean;
  59429. /**
  59430. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  59431. */
  59432. invertNormalMapY: boolean;
  59433. /**
  59434. * Normal map used in the model.
  59435. */
  59436. normalTexture: BaseTexture;
  59437. /**
  59438. * Emissivie color used to self-illuminate the model.
  59439. */
  59440. emissiveColor: Color3;
  59441. /**
  59442. * Emissivie texture used to self-illuminate the model.
  59443. */
  59444. emissiveTexture: BaseTexture;
  59445. /**
  59446. * Occlusion Channel Strenght.
  59447. */
  59448. occlusionStrength: number;
  59449. /**
  59450. * Occlusion Texture of the material (adding extra occlusion effects).
  59451. */
  59452. occlusionTexture: BaseTexture;
  59453. /**
  59454. * Defines the alpha limits in alpha test mode.
  59455. */
  59456. alphaCutOff: number;
  59457. /**
  59458. * Gets the current double sided mode.
  59459. */
  59460. get doubleSided(): boolean;
  59461. /**
  59462. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59463. */
  59464. set doubleSided(value: boolean);
  59465. /**
  59466. * Stores the pre-calculated light information of a mesh in a texture.
  59467. */
  59468. lightmapTexture: BaseTexture;
  59469. /**
  59470. * If true, the light map contains occlusion information instead of lighting info.
  59471. */
  59472. useLightmapAsShadowmap: boolean;
  59473. /**
  59474. * Instantiates a new PBRMaterial instance.
  59475. *
  59476. * @param name The material name
  59477. * @param scene The scene the material will be use in.
  59478. */
  59479. constructor(name: string, scene: Scene);
  59480. getClassName(): string;
  59481. }
  59482. }
  59483. declare module BABYLON {
  59484. /**
  59485. * The PBR material of BJS following the metal roughness convention.
  59486. *
  59487. * This fits to the PBR convention in the GLTF definition:
  59488. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  59489. */
  59490. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  59491. /**
  59492. * The base color has two different interpretations depending on the value of metalness.
  59493. * When the material is a metal, the base color is the specific measured reflectance value
  59494. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  59495. * of the material.
  59496. */
  59497. baseColor: Color3;
  59498. /**
  59499. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  59500. * well as opacity information in the alpha channel.
  59501. */
  59502. baseTexture: BaseTexture;
  59503. /**
  59504. * Specifies the metallic scalar value of the material.
  59505. * Can also be used to scale the metalness values of the metallic texture.
  59506. */
  59507. metallic: number;
  59508. /**
  59509. * Specifies the roughness scalar value of the material.
  59510. * Can also be used to scale the roughness values of the metallic texture.
  59511. */
  59512. roughness: number;
  59513. /**
  59514. * Texture containing both the metallic value in the B channel and the
  59515. * roughness value in the G channel to keep better precision.
  59516. */
  59517. metallicRoughnessTexture: BaseTexture;
  59518. /**
  59519. * Instantiates a new PBRMetalRoughnessMaterial instance.
  59520. *
  59521. * @param name The material name
  59522. * @param scene The scene the material will be use in.
  59523. */
  59524. constructor(name: string, scene: Scene);
  59525. /**
  59526. * Return the currrent class name of the material.
  59527. */
  59528. getClassName(): string;
  59529. /**
  59530. * Makes a duplicate of the current material.
  59531. * @param name - name to use for the new material.
  59532. */
  59533. clone(name: string): PBRMetallicRoughnessMaterial;
  59534. /**
  59535. * Serialize the material to a parsable JSON object.
  59536. */
  59537. serialize(): any;
  59538. /**
  59539. * Parses a JSON object correponding to the serialize function.
  59540. */
  59541. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  59542. }
  59543. }
  59544. declare module BABYLON {
  59545. /**
  59546. * The PBR material of BJS following the specular glossiness convention.
  59547. *
  59548. * This fits to the PBR convention in the GLTF definition:
  59549. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  59550. */
  59551. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  59552. /**
  59553. * Specifies the diffuse color of the material.
  59554. */
  59555. diffuseColor: Color3;
  59556. /**
  59557. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  59558. * channel.
  59559. */
  59560. diffuseTexture: BaseTexture;
  59561. /**
  59562. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  59563. */
  59564. specularColor: Color3;
  59565. /**
  59566. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  59567. */
  59568. glossiness: number;
  59569. /**
  59570. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  59571. */
  59572. specularGlossinessTexture: BaseTexture;
  59573. /**
  59574. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  59575. *
  59576. * @param name The material name
  59577. * @param scene The scene the material will be use in.
  59578. */
  59579. constructor(name: string, scene: Scene);
  59580. /**
  59581. * Return the currrent class name of the material.
  59582. */
  59583. getClassName(): string;
  59584. /**
  59585. * Makes a duplicate of the current material.
  59586. * @param name - name to use for the new material.
  59587. */
  59588. clone(name: string): PBRSpecularGlossinessMaterial;
  59589. /**
  59590. * Serialize the material to a parsable JSON object.
  59591. */
  59592. serialize(): any;
  59593. /**
  59594. * Parses a JSON object correponding to the serialize function.
  59595. */
  59596. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  59597. }
  59598. }
  59599. declare module BABYLON {
  59600. /**
  59601. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  59602. * It can help converting any input color in a desired output one. This can then be used to create effects
  59603. * from sepia, black and white to sixties or futuristic rendering...
  59604. *
  59605. * The only supported format is currently 3dl.
  59606. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  59607. */
  59608. export class ColorGradingTexture extends BaseTexture {
  59609. /**
  59610. * The texture URL.
  59611. */
  59612. url: string;
  59613. /**
  59614. * Empty line regex stored for GC.
  59615. */
  59616. private static _noneEmptyLineRegex;
  59617. private _textureMatrix;
  59618. private _onLoad;
  59619. /**
  59620. * Instantiates a ColorGradingTexture from the following parameters.
  59621. *
  59622. * @param url The location of the color gradind data (currently only supporting 3dl)
  59623. * @param sceneOrEngine The scene or engine the texture will be used in
  59624. * @param onLoad defines a callback triggered when the texture has been loaded
  59625. */
  59626. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  59627. /**
  59628. * Fires the onload event from the constructor if requested.
  59629. */
  59630. private _triggerOnLoad;
  59631. /**
  59632. * Returns the texture matrix used in most of the material.
  59633. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  59634. */
  59635. getTextureMatrix(): Matrix;
  59636. /**
  59637. * Occurs when the file being loaded is a .3dl LUT file.
  59638. */
  59639. private load3dlTexture;
  59640. /**
  59641. * Starts the loading process of the texture.
  59642. */
  59643. private loadTexture;
  59644. /**
  59645. * Clones the color gradind texture.
  59646. */
  59647. clone(): ColorGradingTexture;
  59648. /**
  59649. * Called during delayed load for textures.
  59650. */
  59651. delayLoad(): void;
  59652. /**
  59653. * Parses a color grading texture serialized by Babylon.
  59654. * @param parsedTexture The texture information being parsedTexture
  59655. * @param scene The scene to load the texture in
  59656. * @param rootUrl The root url of the data assets to load
  59657. * @return A color gradind texture
  59658. */
  59659. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  59660. /**
  59661. * Serializes the LUT texture to json format.
  59662. */
  59663. serialize(): any;
  59664. }
  59665. }
  59666. declare module BABYLON {
  59667. /**
  59668. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  59669. */
  59670. export class EquiRectangularCubeTexture extends BaseTexture {
  59671. /** The six faces of the cube. */
  59672. private static _FacesMapping;
  59673. private _noMipmap;
  59674. private _onLoad;
  59675. private _onError;
  59676. /** The size of the cubemap. */
  59677. private _size;
  59678. /** The buffer of the image. */
  59679. private _buffer;
  59680. /** The width of the input image. */
  59681. private _width;
  59682. /** The height of the input image. */
  59683. private _height;
  59684. /** The URL to the image. */
  59685. url: string;
  59686. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  59687. coordinatesMode: number;
  59688. /**
  59689. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  59690. * @param url The location of the image
  59691. * @param scene The scene the texture will be used in
  59692. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  59693. * @param noMipmap Forces to not generate the mipmap if true
  59694. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  59695. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  59696. * @param onLoad — defines a callback called when texture is loaded
  59697. * @param onError — defines a callback called if there is an error
  59698. */
  59699. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  59700. /**
  59701. * Load the image data, by putting the image on a canvas and extracting its buffer.
  59702. */
  59703. private loadImage;
  59704. /**
  59705. * Convert the image buffer into a cubemap and create a CubeTexture.
  59706. */
  59707. private loadTexture;
  59708. /**
  59709. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  59710. * @param buffer The ArrayBuffer that should be converted.
  59711. * @returns The buffer as Float32Array.
  59712. */
  59713. private getFloat32ArrayFromArrayBuffer;
  59714. /**
  59715. * Get the current class name of the texture useful for serialization or dynamic coding.
  59716. * @returns "EquiRectangularCubeTexture"
  59717. */
  59718. getClassName(): string;
  59719. /**
  59720. * Create a clone of the current EquiRectangularCubeTexture and return it.
  59721. * @returns A clone of the current EquiRectangularCubeTexture.
  59722. */
  59723. clone(): EquiRectangularCubeTexture;
  59724. }
  59725. }
  59726. declare module BABYLON {
  59727. /**
  59728. * Defines the options related to the creation of an HtmlElementTexture
  59729. */
  59730. export interface IHtmlElementTextureOptions {
  59731. /**
  59732. * Defines wether mip maps should be created or not.
  59733. */
  59734. generateMipMaps?: boolean;
  59735. /**
  59736. * Defines the sampling mode of the texture.
  59737. */
  59738. samplingMode?: number;
  59739. /**
  59740. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  59741. */
  59742. engine: Nullable<ThinEngine>;
  59743. /**
  59744. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  59745. */
  59746. scene: Nullable<Scene>;
  59747. }
  59748. /**
  59749. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  59750. * To be as efficient as possible depending on your constraints nothing aside the first upload
  59751. * is automatically managed.
  59752. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  59753. * in your application.
  59754. *
  59755. * As the update is not automatic, you need to call them manually.
  59756. */
  59757. export class HtmlElementTexture extends BaseTexture {
  59758. /**
  59759. * The texture URL.
  59760. */
  59761. element: HTMLVideoElement | HTMLCanvasElement;
  59762. private static readonly DefaultOptions;
  59763. private _textureMatrix;
  59764. private _isVideo;
  59765. private _generateMipMaps;
  59766. private _samplingMode;
  59767. /**
  59768. * Instantiates a HtmlElementTexture from the following parameters.
  59769. *
  59770. * @param name Defines the name of the texture
  59771. * @param element Defines the video or canvas the texture is filled with
  59772. * @param options Defines the other none mandatory texture creation options
  59773. */
  59774. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  59775. private _createInternalTexture;
  59776. /**
  59777. * Returns the texture matrix used in most of the material.
  59778. */
  59779. getTextureMatrix(): Matrix;
  59780. /**
  59781. * Updates the content of the texture.
  59782. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  59783. */
  59784. update(invertY?: Nullable<boolean>): void;
  59785. }
  59786. }
  59787. declare module BABYLON {
  59788. /**
  59789. * Based on jsTGALoader - Javascript loader for TGA file
  59790. * By Vincent Thibault
  59791. * @see http://blog.robrowser.com/javascript-tga-loader.html
  59792. */
  59793. export class TGATools {
  59794. private static _TYPE_INDEXED;
  59795. private static _TYPE_RGB;
  59796. private static _TYPE_GREY;
  59797. private static _TYPE_RLE_INDEXED;
  59798. private static _TYPE_RLE_RGB;
  59799. private static _TYPE_RLE_GREY;
  59800. private static _ORIGIN_MASK;
  59801. private static _ORIGIN_SHIFT;
  59802. private static _ORIGIN_BL;
  59803. private static _ORIGIN_BR;
  59804. private static _ORIGIN_UL;
  59805. private static _ORIGIN_UR;
  59806. /**
  59807. * Gets the header of a TGA file
  59808. * @param data defines the TGA data
  59809. * @returns the header
  59810. */
  59811. static GetTGAHeader(data: Uint8Array): any;
  59812. /**
  59813. * Uploads TGA content to a Babylon Texture
  59814. * @hidden
  59815. */
  59816. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  59817. /** @hidden */
  59818. 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;
  59819. /** @hidden */
  59820. 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;
  59821. /** @hidden */
  59822. 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;
  59823. /** @hidden */
  59824. 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;
  59825. /** @hidden */
  59826. 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;
  59827. /** @hidden */
  59828. 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;
  59829. }
  59830. }
  59831. declare module BABYLON {
  59832. /**
  59833. * Implementation of the TGA Texture Loader.
  59834. * @hidden
  59835. */
  59836. export class _TGATextureLoader implements IInternalTextureLoader {
  59837. /**
  59838. * Defines wether the loader supports cascade loading the different faces.
  59839. */
  59840. readonly supportCascades: boolean;
  59841. /**
  59842. * This returns if the loader support the current file information.
  59843. * @param extension defines the file extension of the file being loaded
  59844. * @returns true if the loader can load the specified file
  59845. */
  59846. canLoad(extension: string): boolean;
  59847. /**
  59848. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59849. * @param data contains the texture data
  59850. * @param texture defines the BabylonJS internal texture
  59851. * @param createPolynomials will be true if polynomials have been requested
  59852. * @param onLoad defines the callback to trigger once the texture is ready
  59853. * @param onError defines the callback to trigger in case of error
  59854. */
  59855. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59856. /**
  59857. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59858. * @param data contains the texture data
  59859. * @param texture defines the BabylonJS internal texture
  59860. * @param callback defines the method to call once ready to upload
  59861. */
  59862. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59863. }
  59864. }
  59865. declare module BABYLON {
  59866. /**
  59867. * Info about the .basis files
  59868. */
  59869. class BasisFileInfo {
  59870. /**
  59871. * If the file has alpha
  59872. */
  59873. hasAlpha: boolean;
  59874. /**
  59875. * Info about each image of the basis file
  59876. */
  59877. images: Array<{
  59878. levels: Array<{
  59879. width: number;
  59880. height: number;
  59881. transcodedPixels: ArrayBufferView;
  59882. }>;
  59883. }>;
  59884. }
  59885. /**
  59886. * Result of transcoding a basis file
  59887. */
  59888. class TranscodeResult {
  59889. /**
  59890. * Info about the .basis file
  59891. */
  59892. fileInfo: BasisFileInfo;
  59893. /**
  59894. * Format to use when loading the file
  59895. */
  59896. format: number;
  59897. }
  59898. /**
  59899. * Configuration options for the Basis transcoder
  59900. */
  59901. export class BasisTranscodeConfiguration {
  59902. /**
  59903. * Supported compression formats used to determine the supported output format of the transcoder
  59904. */
  59905. supportedCompressionFormats?: {
  59906. /**
  59907. * etc1 compression format
  59908. */
  59909. etc1?: boolean;
  59910. /**
  59911. * s3tc compression format
  59912. */
  59913. s3tc?: boolean;
  59914. /**
  59915. * pvrtc compression format
  59916. */
  59917. pvrtc?: boolean;
  59918. /**
  59919. * etc2 compression format
  59920. */
  59921. etc2?: boolean;
  59922. };
  59923. /**
  59924. * If mipmap levels should be loaded for transcoded images (Default: true)
  59925. */
  59926. loadMipmapLevels?: boolean;
  59927. /**
  59928. * Index of a single image to load (Default: all images)
  59929. */
  59930. loadSingleImage?: number;
  59931. }
  59932. /**
  59933. * Used to load .Basis files
  59934. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  59935. */
  59936. export class BasisTools {
  59937. private static _IgnoreSupportedFormats;
  59938. /**
  59939. * URL to use when loading the basis transcoder
  59940. */
  59941. static JSModuleURL: string;
  59942. /**
  59943. * URL to use when loading the wasm module for the transcoder
  59944. */
  59945. static WasmModuleURL: string;
  59946. /**
  59947. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  59948. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  59949. * @returns internal format corresponding to the Basis format
  59950. */
  59951. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  59952. private static _WorkerPromise;
  59953. private static _Worker;
  59954. private static _actionId;
  59955. private static _CreateWorkerAsync;
  59956. /**
  59957. * Transcodes a loaded image file to compressed pixel data
  59958. * @param data image data to transcode
  59959. * @param config configuration options for the transcoding
  59960. * @returns a promise resulting in the transcoded image
  59961. */
  59962. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  59963. /**
  59964. * Loads a texture from the transcode result
  59965. * @param texture texture load to
  59966. * @param transcodeResult the result of transcoding the basis file to load from
  59967. */
  59968. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  59969. }
  59970. }
  59971. declare module BABYLON {
  59972. /**
  59973. * Loader for .basis file format
  59974. */
  59975. export class _BasisTextureLoader implements IInternalTextureLoader {
  59976. /**
  59977. * Defines whether the loader supports cascade loading the different faces.
  59978. */
  59979. readonly supportCascades: boolean;
  59980. /**
  59981. * This returns if the loader support the current file information.
  59982. * @param extension defines the file extension of the file being loaded
  59983. * @returns true if the loader can load the specified file
  59984. */
  59985. canLoad(extension: string): boolean;
  59986. /**
  59987. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59988. * @param data contains the texture data
  59989. * @param texture defines the BabylonJS internal texture
  59990. * @param createPolynomials will be true if polynomials have been requested
  59991. * @param onLoad defines the callback to trigger once the texture is ready
  59992. * @param onError defines the callback to trigger in case of error
  59993. */
  59994. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59995. /**
  59996. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59997. * @param data contains the texture data
  59998. * @param texture defines the BabylonJS internal texture
  59999. * @param callback defines the method to call once ready to upload
  60000. */
  60001. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60002. }
  60003. }
  60004. declare module BABYLON {
  60005. /**
  60006. * Defines the basic options interface of a TexturePacker Frame
  60007. */
  60008. export interface ITexturePackerFrame {
  60009. /**
  60010. * The frame ID
  60011. */
  60012. id: number;
  60013. /**
  60014. * The frames Scale
  60015. */
  60016. scale: Vector2;
  60017. /**
  60018. * The Frames offset
  60019. */
  60020. offset: Vector2;
  60021. }
  60022. /**
  60023. * This is a support class for frame Data on texture packer sets.
  60024. */
  60025. export class TexturePackerFrame implements ITexturePackerFrame {
  60026. /**
  60027. * The frame ID
  60028. */
  60029. id: number;
  60030. /**
  60031. * The frames Scale
  60032. */
  60033. scale: Vector2;
  60034. /**
  60035. * The Frames offset
  60036. */
  60037. offset: Vector2;
  60038. /**
  60039. * Initializes a texture package frame.
  60040. * @param id The numerical frame identifier
  60041. * @param scale Scalar Vector2 for UV frame
  60042. * @param offset Vector2 for the frame position in UV units.
  60043. * @returns TexturePackerFrame
  60044. */
  60045. constructor(id: number, scale: Vector2, offset: Vector2);
  60046. }
  60047. }
  60048. declare module BABYLON {
  60049. /**
  60050. * Defines the basic options interface of a TexturePacker
  60051. */
  60052. export interface ITexturePackerOptions {
  60053. /**
  60054. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  60055. */
  60056. map?: string[];
  60057. /**
  60058. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60059. */
  60060. uvsIn?: string;
  60061. /**
  60062. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60063. */
  60064. uvsOut?: string;
  60065. /**
  60066. * number representing the layout style. Defaults to LAYOUT_STRIP
  60067. */
  60068. layout?: number;
  60069. /**
  60070. * number of columns if using custom column count layout(2). This defaults to 4.
  60071. */
  60072. colnum?: number;
  60073. /**
  60074. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  60075. */
  60076. updateInputMeshes?: boolean;
  60077. /**
  60078. * boolean flag to dispose all the source textures. Defaults to true.
  60079. */
  60080. disposeSources?: boolean;
  60081. /**
  60082. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  60083. */
  60084. fillBlanks?: boolean;
  60085. /**
  60086. * string value representing the context fill style color. Defaults to 'black'.
  60087. */
  60088. customFillColor?: string;
  60089. /**
  60090. * Width and Height Value of each Frame in the TexturePacker Sets
  60091. */
  60092. frameSize?: number;
  60093. /**
  60094. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  60095. */
  60096. paddingRatio?: number;
  60097. /**
  60098. * Number that declares the fill method for the padding gutter.
  60099. */
  60100. paddingMode?: number;
  60101. /**
  60102. * If in SUBUV_COLOR padding mode what color to use.
  60103. */
  60104. paddingColor?: Color3 | Color4;
  60105. }
  60106. /**
  60107. * Defines the basic interface of a TexturePacker JSON File
  60108. */
  60109. export interface ITexturePackerJSON {
  60110. /**
  60111. * The frame ID
  60112. */
  60113. name: string;
  60114. /**
  60115. * The base64 channel data
  60116. */
  60117. sets: any;
  60118. /**
  60119. * The options of the Packer
  60120. */
  60121. options: ITexturePackerOptions;
  60122. /**
  60123. * The frame data of the Packer
  60124. */
  60125. frames: Array<number>;
  60126. }
  60127. /**
  60128. * This is a support class that generates a series of packed texture sets.
  60129. * @see https://doc.babylonjs.com/babylon101/materials
  60130. */
  60131. export class TexturePacker {
  60132. /** Packer Layout Constant 0 */
  60133. static readonly LAYOUT_STRIP: number;
  60134. /** Packer Layout Constant 1 */
  60135. static readonly LAYOUT_POWER2: number;
  60136. /** Packer Layout Constant 2 */
  60137. static readonly LAYOUT_COLNUM: number;
  60138. /** Packer Layout Constant 0 */
  60139. static readonly SUBUV_WRAP: number;
  60140. /** Packer Layout Constant 1 */
  60141. static readonly SUBUV_EXTEND: number;
  60142. /** Packer Layout Constant 2 */
  60143. static readonly SUBUV_COLOR: number;
  60144. /** The Name of the Texture Package */
  60145. name: string;
  60146. /** The scene scope of the TexturePacker */
  60147. scene: Scene;
  60148. /** The Meshes to target */
  60149. meshes: AbstractMesh[];
  60150. /** Arguments passed with the Constructor */
  60151. options: ITexturePackerOptions;
  60152. /** The promise that is started upon initialization */
  60153. promise: Nullable<Promise<TexturePacker | string>>;
  60154. /** The Container object for the channel sets that are generated */
  60155. sets: object;
  60156. /** The Container array for the frames that are generated */
  60157. frames: TexturePackerFrame[];
  60158. /** The expected number of textures the system is parsing. */
  60159. private _expecting;
  60160. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  60161. private _paddingValue;
  60162. /**
  60163. * Initializes a texture package series from an array of meshes or a single mesh.
  60164. * @param name The name of the package
  60165. * @param meshes The target meshes to compose the package from
  60166. * @param options The arguments that texture packer should follow while building.
  60167. * @param scene The scene which the textures are scoped to.
  60168. * @returns TexturePacker
  60169. */
  60170. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  60171. /**
  60172. * Starts the package process
  60173. * @param resolve The promises resolution function
  60174. * @returns TexturePacker
  60175. */
  60176. private _createFrames;
  60177. /**
  60178. * Calculates the Size of the Channel Sets
  60179. * @returns Vector2
  60180. */
  60181. private _calculateSize;
  60182. /**
  60183. * Calculates the UV data for the frames.
  60184. * @param baseSize the base frameSize
  60185. * @param padding the base frame padding
  60186. * @param dtSize size of the Dynamic Texture for that channel
  60187. * @param dtUnits is 1/dtSize
  60188. * @param update flag to update the input meshes
  60189. */
  60190. private _calculateMeshUVFrames;
  60191. /**
  60192. * Calculates the frames Offset.
  60193. * @param index of the frame
  60194. * @returns Vector2
  60195. */
  60196. private _getFrameOffset;
  60197. /**
  60198. * Updates a Mesh to the frame data
  60199. * @param mesh that is the target
  60200. * @param frameID or the frame index
  60201. */
  60202. private _updateMeshUV;
  60203. /**
  60204. * Updates a Meshes materials to use the texture packer channels
  60205. * @param m is the mesh to target
  60206. * @param force all channels on the packer to be set.
  60207. */
  60208. private _updateTextureReferences;
  60209. /**
  60210. * Public method to set a Mesh to a frame
  60211. * @param m that is the target
  60212. * @param frameID or the frame index
  60213. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  60214. */
  60215. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  60216. /**
  60217. * Starts the async promise to compile the texture packer.
  60218. * @returns Promise<void>
  60219. */
  60220. processAsync(): Promise<void>;
  60221. /**
  60222. * Disposes all textures associated with this packer
  60223. */
  60224. dispose(): void;
  60225. /**
  60226. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  60227. * @param imageType is the image type to use.
  60228. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  60229. */
  60230. download(imageType?: string, quality?: number): void;
  60231. /**
  60232. * Public method to load a texturePacker JSON file.
  60233. * @param data of the JSON file in string format.
  60234. */
  60235. updateFromJSON(data: string): void;
  60236. }
  60237. }
  60238. declare module BABYLON {
  60239. /**
  60240. * 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.
  60241. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  60242. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  60243. */
  60244. export class CustomProceduralTexture extends ProceduralTexture {
  60245. private _animate;
  60246. private _time;
  60247. private _config;
  60248. private _texturePath;
  60249. /**
  60250. * Instantiates a new Custom Procedural Texture.
  60251. * 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.
  60252. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  60253. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  60254. * @param name Define the name of the texture
  60255. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  60256. * @param size Define the size of the texture to create
  60257. * @param scene Define the scene the texture belongs to
  60258. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  60259. * @param generateMipMaps Define if the texture should creates mip maps or not
  60260. */
  60261. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  60262. private _loadJson;
  60263. /**
  60264. * Is the texture ready to be used ? (rendered at least once)
  60265. * @returns true if ready, otherwise, false.
  60266. */
  60267. isReady(): boolean;
  60268. /**
  60269. * Render the texture to its associated render target.
  60270. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  60271. */
  60272. render(useCameraPostProcess?: boolean): void;
  60273. /**
  60274. * Update the list of dependant textures samplers in the shader.
  60275. */
  60276. updateTextures(): void;
  60277. /**
  60278. * Update the uniform values of the procedural texture in the shader.
  60279. */
  60280. updateShaderUniforms(): void;
  60281. /**
  60282. * Define if the texture animates or not.
  60283. */
  60284. get animate(): boolean;
  60285. set animate(value: boolean);
  60286. }
  60287. }
  60288. declare module BABYLON {
  60289. /** @hidden */
  60290. export var noisePixelShader: {
  60291. name: string;
  60292. shader: string;
  60293. };
  60294. }
  60295. declare module BABYLON {
  60296. /**
  60297. * Class used to generate noise procedural textures
  60298. */
  60299. export class NoiseProceduralTexture extends ProceduralTexture {
  60300. private _time;
  60301. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  60302. brightness: number;
  60303. /** Defines the number of octaves to process */
  60304. octaves: number;
  60305. /** Defines the level of persistence (0.8 by default) */
  60306. persistence: number;
  60307. /** Gets or sets animation speed factor (default is 1) */
  60308. animationSpeedFactor: number;
  60309. /**
  60310. * Creates a new NoiseProceduralTexture
  60311. * @param name defines the name fo the texture
  60312. * @param size defines the size of the texture (default is 256)
  60313. * @param scene defines the hosting scene
  60314. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  60315. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  60316. */
  60317. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  60318. private _updateShaderUniforms;
  60319. protected _getDefines(): string;
  60320. /** Generate the current state of the procedural texture */
  60321. render(useCameraPostProcess?: boolean): void;
  60322. /**
  60323. * Serializes this noise procedural texture
  60324. * @returns a serialized noise procedural texture object
  60325. */
  60326. serialize(): any;
  60327. /**
  60328. * Clone the texture.
  60329. * @returns the cloned texture
  60330. */
  60331. clone(): NoiseProceduralTexture;
  60332. /**
  60333. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  60334. * @param parsedTexture defines parsed texture data
  60335. * @param scene defines the current scene
  60336. * @param rootUrl defines the root URL containing noise procedural texture information
  60337. * @returns a parsed NoiseProceduralTexture
  60338. */
  60339. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  60340. }
  60341. }
  60342. declare module BABYLON {
  60343. /**
  60344. * Raw cube texture where the raw buffers are passed in
  60345. */
  60346. export class RawCubeTexture extends CubeTexture {
  60347. /**
  60348. * Creates a cube texture where the raw buffers are passed in.
  60349. * @param scene defines the scene the texture is attached to
  60350. * @param data defines the array of data to use to create each face
  60351. * @param size defines the size of the textures
  60352. * @param format defines the format of the data
  60353. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  60354. * @param generateMipMaps defines if the engine should generate the mip levels
  60355. * @param invertY defines if data must be stored with Y axis inverted
  60356. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  60357. * @param compression defines the compression used (null by default)
  60358. */
  60359. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  60360. /**
  60361. * Updates the raw cube texture.
  60362. * @param data defines the data to store
  60363. * @param format defines the data format
  60364. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  60365. * @param invertY defines if data must be stored with Y axis inverted
  60366. * @param compression defines the compression used (null by default)
  60367. * @param level defines which level of the texture to update
  60368. */
  60369. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  60370. /**
  60371. * Updates a raw cube texture with RGBD encoded data.
  60372. * @param data defines the array of data [mipmap][face] to use to create each face
  60373. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  60374. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  60375. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  60376. * @returns a promsie that resolves when the operation is complete
  60377. */
  60378. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  60379. /**
  60380. * Clones the raw cube texture.
  60381. * @return a new cube texture
  60382. */
  60383. clone(): CubeTexture;
  60384. /** @hidden */
  60385. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  60386. }
  60387. }
  60388. declare module BABYLON {
  60389. /**
  60390. * Class used to store 2D array textures containing user data
  60391. */
  60392. export class RawTexture2DArray extends Texture {
  60393. /** Gets or sets the texture format to use */
  60394. format: number;
  60395. /**
  60396. * Create a new RawTexture2DArray
  60397. * @param data defines the data of the texture
  60398. * @param width defines the width of the texture
  60399. * @param height defines the height of the texture
  60400. * @param depth defines the number of layers of the texture
  60401. * @param format defines the texture format to use
  60402. * @param scene defines the hosting scene
  60403. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  60404. * @param invertY defines if texture must be stored with Y axis inverted
  60405. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60406. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  60407. */
  60408. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  60409. /** Gets or sets the texture format to use */
  60410. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  60411. /**
  60412. * Update the texture with new data
  60413. * @param data defines the data to store in the texture
  60414. */
  60415. update(data: ArrayBufferView): void;
  60416. }
  60417. }
  60418. declare module BABYLON {
  60419. /**
  60420. * Class used to store 3D textures containing user data
  60421. */
  60422. export class RawTexture3D extends Texture {
  60423. /** Gets or sets the texture format to use */
  60424. format: number;
  60425. /**
  60426. * Create a new RawTexture3D
  60427. * @param data defines the data of the texture
  60428. * @param width defines the width of the texture
  60429. * @param height defines the height of the texture
  60430. * @param depth defines the depth of the texture
  60431. * @param format defines the texture format to use
  60432. * @param scene defines the hosting scene
  60433. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  60434. * @param invertY defines if texture must be stored with Y axis inverted
  60435. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60436. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  60437. */
  60438. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  60439. /** Gets or sets the texture format to use */
  60440. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  60441. /**
  60442. * Update the texture with new data
  60443. * @param data defines the data to store in the texture
  60444. */
  60445. update(data: ArrayBufferView): void;
  60446. }
  60447. }
  60448. declare module BABYLON {
  60449. /**
  60450. * Creates a refraction texture used by refraction channel of the standard material.
  60451. * It is like a mirror but to see through a material.
  60452. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60453. */
  60454. export class RefractionTexture extends RenderTargetTexture {
  60455. /**
  60456. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  60457. * 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.
  60458. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60459. */
  60460. refractionPlane: Plane;
  60461. /**
  60462. * Define how deep under the surface we should see.
  60463. */
  60464. depth: number;
  60465. /**
  60466. * Creates a refraction texture used by refraction channel of the standard material.
  60467. * It is like a mirror but to see through a material.
  60468. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60469. * @param name Define the texture name
  60470. * @param size Define the size of the underlying texture
  60471. * @param scene Define the scene the refraction belongs to
  60472. * @param generateMipMaps Define if we need to generate mips level for the refraction
  60473. */
  60474. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  60475. /**
  60476. * Clone the refraction texture.
  60477. * @returns the cloned texture
  60478. */
  60479. clone(): RefractionTexture;
  60480. /**
  60481. * Serialize the texture to a JSON representation you could use in Parse later on
  60482. * @returns the serialized JSON representation
  60483. */
  60484. serialize(): any;
  60485. }
  60486. }
  60487. declare module BABYLON {
  60488. /**
  60489. * Block used to add support for vertex skinning (bones)
  60490. */
  60491. export class BonesBlock extends NodeMaterialBlock {
  60492. /**
  60493. * Creates a new BonesBlock
  60494. * @param name defines the block name
  60495. */
  60496. constructor(name: string);
  60497. /**
  60498. * Initialize the block and prepare the context for build
  60499. * @param state defines the state that will be used for the build
  60500. */
  60501. initialize(state: NodeMaterialBuildState): void;
  60502. /**
  60503. * Gets the current class name
  60504. * @returns the class name
  60505. */
  60506. getClassName(): string;
  60507. /**
  60508. * Gets the matrix indices input component
  60509. */
  60510. get matricesIndices(): NodeMaterialConnectionPoint;
  60511. /**
  60512. * Gets the matrix weights input component
  60513. */
  60514. get matricesWeights(): NodeMaterialConnectionPoint;
  60515. /**
  60516. * Gets the extra matrix indices input component
  60517. */
  60518. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  60519. /**
  60520. * Gets the extra matrix weights input component
  60521. */
  60522. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  60523. /**
  60524. * Gets the world input component
  60525. */
  60526. get world(): NodeMaterialConnectionPoint;
  60527. /**
  60528. * Gets the output component
  60529. */
  60530. get output(): NodeMaterialConnectionPoint;
  60531. autoConfigure(material: NodeMaterial): void;
  60532. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60533. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60534. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60535. protected _buildBlock(state: NodeMaterialBuildState): this;
  60536. }
  60537. }
  60538. declare module BABYLON {
  60539. /**
  60540. * Block used to add support for instances
  60541. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  60542. */
  60543. export class InstancesBlock extends NodeMaterialBlock {
  60544. /**
  60545. * Creates a new InstancesBlock
  60546. * @param name defines the block name
  60547. */
  60548. constructor(name: string);
  60549. /**
  60550. * Gets the current class name
  60551. * @returns the class name
  60552. */
  60553. getClassName(): string;
  60554. /**
  60555. * Gets the first world row input component
  60556. */
  60557. get world0(): NodeMaterialConnectionPoint;
  60558. /**
  60559. * Gets the second world row input component
  60560. */
  60561. get world1(): NodeMaterialConnectionPoint;
  60562. /**
  60563. * Gets the third world row input component
  60564. */
  60565. get world2(): NodeMaterialConnectionPoint;
  60566. /**
  60567. * Gets the forth world row input component
  60568. */
  60569. get world3(): NodeMaterialConnectionPoint;
  60570. /**
  60571. * Gets the world input component
  60572. */
  60573. get world(): NodeMaterialConnectionPoint;
  60574. /**
  60575. * Gets the output component
  60576. */
  60577. get output(): NodeMaterialConnectionPoint;
  60578. /**
  60579. * Gets the isntanceID component
  60580. */
  60581. get instanceID(): NodeMaterialConnectionPoint;
  60582. autoConfigure(material: NodeMaterial): void;
  60583. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60584. protected _buildBlock(state: NodeMaterialBuildState): this;
  60585. }
  60586. }
  60587. declare module BABYLON {
  60588. /**
  60589. * Block used to add morph targets support to vertex shader
  60590. */
  60591. export class MorphTargetsBlock extends NodeMaterialBlock {
  60592. private _repeatableContentAnchor;
  60593. /**
  60594. * Create a new MorphTargetsBlock
  60595. * @param name defines the block name
  60596. */
  60597. constructor(name: string);
  60598. /**
  60599. * Gets the current class name
  60600. * @returns the class name
  60601. */
  60602. getClassName(): string;
  60603. /**
  60604. * Gets the position input component
  60605. */
  60606. get position(): NodeMaterialConnectionPoint;
  60607. /**
  60608. * Gets the normal input component
  60609. */
  60610. get normal(): NodeMaterialConnectionPoint;
  60611. /**
  60612. * Gets the tangent input component
  60613. */
  60614. get tangent(): NodeMaterialConnectionPoint;
  60615. /**
  60616. * Gets the tangent input component
  60617. */
  60618. get uv(): NodeMaterialConnectionPoint;
  60619. /**
  60620. * Gets the position output component
  60621. */
  60622. get positionOutput(): NodeMaterialConnectionPoint;
  60623. /**
  60624. * Gets the normal output component
  60625. */
  60626. get normalOutput(): NodeMaterialConnectionPoint;
  60627. /**
  60628. * Gets the tangent output component
  60629. */
  60630. get tangentOutput(): NodeMaterialConnectionPoint;
  60631. /**
  60632. * Gets the tangent output component
  60633. */
  60634. get uvOutput(): NodeMaterialConnectionPoint;
  60635. initialize(state: NodeMaterialBuildState): void;
  60636. autoConfigure(material: NodeMaterial): void;
  60637. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60638. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60639. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60640. protected _buildBlock(state: NodeMaterialBuildState): this;
  60641. }
  60642. }
  60643. declare module BABYLON {
  60644. /**
  60645. * Block used to get data information from a light
  60646. */
  60647. export class LightInformationBlock extends NodeMaterialBlock {
  60648. private _lightDataUniformName;
  60649. private _lightColorUniformName;
  60650. private _lightTypeDefineName;
  60651. /**
  60652. * Gets or sets the light associated with this block
  60653. */
  60654. light: Nullable<Light>;
  60655. /**
  60656. * Creates a new LightInformationBlock
  60657. * @param name defines the block name
  60658. */
  60659. constructor(name: string);
  60660. /**
  60661. * Gets the current class name
  60662. * @returns the class name
  60663. */
  60664. getClassName(): string;
  60665. /**
  60666. * Gets the world position input component
  60667. */
  60668. get worldPosition(): NodeMaterialConnectionPoint;
  60669. /**
  60670. * Gets the direction output component
  60671. */
  60672. get direction(): NodeMaterialConnectionPoint;
  60673. /**
  60674. * Gets the direction output component
  60675. */
  60676. get color(): NodeMaterialConnectionPoint;
  60677. /**
  60678. * Gets the direction output component
  60679. */
  60680. get intensity(): NodeMaterialConnectionPoint;
  60681. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60682. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60683. protected _buildBlock(state: NodeMaterialBuildState): this;
  60684. serialize(): any;
  60685. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60686. }
  60687. }
  60688. declare module BABYLON {
  60689. /**
  60690. * Block used to add image processing support to fragment shader
  60691. */
  60692. export class ImageProcessingBlock extends NodeMaterialBlock {
  60693. /**
  60694. * Create a new ImageProcessingBlock
  60695. * @param name defines the block name
  60696. */
  60697. constructor(name: string);
  60698. /**
  60699. * Gets the current class name
  60700. * @returns the class name
  60701. */
  60702. getClassName(): string;
  60703. /**
  60704. * Gets the color input component
  60705. */
  60706. get color(): NodeMaterialConnectionPoint;
  60707. /**
  60708. * Gets the output component
  60709. */
  60710. get output(): NodeMaterialConnectionPoint;
  60711. /**
  60712. * Initialize the block and prepare the context for build
  60713. * @param state defines the state that will be used for the build
  60714. */
  60715. initialize(state: NodeMaterialBuildState): void;
  60716. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  60717. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60718. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60719. protected _buildBlock(state: NodeMaterialBuildState): this;
  60720. }
  60721. }
  60722. declare module BABYLON {
  60723. /**
  60724. * Block used to pertub normals based on a normal map
  60725. */
  60726. export class PerturbNormalBlock extends NodeMaterialBlock {
  60727. private _tangentSpaceParameterName;
  60728. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  60729. invertX: boolean;
  60730. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  60731. invertY: boolean;
  60732. /**
  60733. * Create a new PerturbNormalBlock
  60734. * @param name defines the block name
  60735. */
  60736. constructor(name: string);
  60737. /**
  60738. * Gets the current class name
  60739. * @returns the class name
  60740. */
  60741. getClassName(): string;
  60742. /**
  60743. * Gets the world position input component
  60744. */
  60745. get worldPosition(): NodeMaterialConnectionPoint;
  60746. /**
  60747. * Gets the world normal input component
  60748. */
  60749. get worldNormal(): NodeMaterialConnectionPoint;
  60750. /**
  60751. * Gets the world tangent input component
  60752. */
  60753. get worldTangent(): NodeMaterialConnectionPoint;
  60754. /**
  60755. * Gets the uv input component
  60756. */
  60757. get uv(): NodeMaterialConnectionPoint;
  60758. /**
  60759. * Gets the normal map color input component
  60760. */
  60761. get normalMapColor(): NodeMaterialConnectionPoint;
  60762. /**
  60763. * Gets the strength input component
  60764. */
  60765. get strength(): NodeMaterialConnectionPoint;
  60766. /**
  60767. * Gets the output component
  60768. */
  60769. get output(): NodeMaterialConnectionPoint;
  60770. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60771. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60772. autoConfigure(material: NodeMaterial): void;
  60773. protected _buildBlock(state: NodeMaterialBuildState): this;
  60774. protected _dumpPropertiesCode(): string;
  60775. serialize(): any;
  60776. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60777. }
  60778. }
  60779. declare module BABYLON {
  60780. /**
  60781. * Block used to discard a pixel if a value is smaller than a cutoff
  60782. */
  60783. export class DiscardBlock extends NodeMaterialBlock {
  60784. /**
  60785. * Create a new DiscardBlock
  60786. * @param name defines the block name
  60787. */
  60788. constructor(name: string);
  60789. /**
  60790. * Gets the current class name
  60791. * @returns the class name
  60792. */
  60793. getClassName(): string;
  60794. /**
  60795. * Gets the color input component
  60796. */
  60797. get value(): NodeMaterialConnectionPoint;
  60798. /**
  60799. * Gets the cutoff input component
  60800. */
  60801. get cutoff(): NodeMaterialConnectionPoint;
  60802. protected _buildBlock(state: NodeMaterialBuildState): this;
  60803. }
  60804. }
  60805. declare module BABYLON {
  60806. /**
  60807. * Block used to test if the fragment shader is front facing
  60808. */
  60809. export class FrontFacingBlock extends NodeMaterialBlock {
  60810. /**
  60811. * Creates a new FrontFacingBlock
  60812. * @param name defines the block name
  60813. */
  60814. constructor(name: string);
  60815. /**
  60816. * Gets the current class name
  60817. * @returns the class name
  60818. */
  60819. getClassName(): string;
  60820. /**
  60821. * Gets the output component
  60822. */
  60823. get output(): NodeMaterialConnectionPoint;
  60824. protected _buildBlock(state: NodeMaterialBuildState): this;
  60825. }
  60826. }
  60827. declare module BABYLON {
  60828. /**
  60829. * Block used to get the derivative value on x and y of a given input
  60830. */
  60831. export class DerivativeBlock extends NodeMaterialBlock {
  60832. /**
  60833. * Create a new DerivativeBlock
  60834. * @param name defines the block name
  60835. */
  60836. constructor(name: string);
  60837. /**
  60838. * Gets the current class name
  60839. * @returns the class name
  60840. */
  60841. getClassName(): string;
  60842. /**
  60843. * Gets the input component
  60844. */
  60845. get input(): NodeMaterialConnectionPoint;
  60846. /**
  60847. * Gets the derivative output on x
  60848. */
  60849. get dx(): NodeMaterialConnectionPoint;
  60850. /**
  60851. * Gets the derivative output on y
  60852. */
  60853. get dy(): NodeMaterialConnectionPoint;
  60854. protected _buildBlock(state: NodeMaterialBuildState): this;
  60855. }
  60856. }
  60857. declare module BABYLON {
  60858. /**
  60859. * Block used to add support for scene fog
  60860. */
  60861. export class FogBlock extends NodeMaterialBlock {
  60862. private _fogDistanceName;
  60863. private _fogParameters;
  60864. /**
  60865. * Create a new FogBlock
  60866. * @param name defines the block name
  60867. */
  60868. constructor(name: string);
  60869. /**
  60870. * Gets the current class name
  60871. * @returns the class name
  60872. */
  60873. getClassName(): string;
  60874. /**
  60875. * Gets the world position input component
  60876. */
  60877. get worldPosition(): NodeMaterialConnectionPoint;
  60878. /**
  60879. * Gets the view input component
  60880. */
  60881. get view(): NodeMaterialConnectionPoint;
  60882. /**
  60883. * Gets the color input component
  60884. */
  60885. get input(): NodeMaterialConnectionPoint;
  60886. /**
  60887. * Gets the fog color input component
  60888. */
  60889. get fogColor(): NodeMaterialConnectionPoint;
  60890. /**
  60891. * Gets the output component
  60892. */
  60893. get output(): NodeMaterialConnectionPoint;
  60894. autoConfigure(material: NodeMaterial): void;
  60895. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60896. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60897. protected _buildBlock(state: NodeMaterialBuildState): this;
  60898. }
  60899. }
  60900. declare module BABYLON {
  60901. /**
  60902. * Block used to add light in the fragment shader
  60903. */
  60904. export class LightBlock extends NodeMaterialBlock {
  60905. private _lightId;
  60906. /**
  60907. * Gets or sets the light associated with this block
  60908. */
  60909. light: Nullable<Light>;
  60910. /**
  60911. * Create a new LightBlock
  60912. * @param name defines the block name
  60913. */
  60914. constructor(name: string);
  60915. /**
  60916. * Gets the current class name
  60917. * @returns the class name
  60918. */
  60919. getClassName(): string;
  60920. /**
  60921. * Gets the world position input component
  60922. */
  60923. get worldPosition(): NodeMaterialConnectionPoint;
  60924. /**
  60925. * Gets the world normal input component
  60926. */
  60927. get worldNormal(): NodeMaterialConnectionPoint;
  60928. /**
  60929. * Gets the camera (or eye) position component
  60930. */
  60931. get cameraPosition(): NodeMaterialConnectionPoint;
  60932. /**
  60933. * Gets the glossiness component
  60934. */
  60935. get glossiness(): NodeMaterialConnectionPoint;
  60936. /**
  60937. * Gets the glossinness power component
  60938. */
  60939. get glossPower(): NodeMaterialConnectionPoint;
  60940. /**
  60941. * Gets the diffuse color component
  60942. */
  60943. get diffuseColor(): NodeMaterialConnectionPoint;
  60944. /**
  60945. * Gets the specular color component
  60946. */
  60947. get specularColor(): NodeMaterialConnectionPoint;
  60948. /**
  60949. * Gets the diffuse output component
  60950. */
  60951. get diffuseOutput(): NodeMaterialConnectionPoint;
  60952. /**
  60953. * Gets the specular output component
  60954. */
  60955. get specularOutput(): NodeMaterialConnectionPoint;
  60956. /**
  60957. * Gets the shadow output component
  60958. */
  60959. get shadow(): NodeMaterialConnectionPoint;
  60960. autoConfigure(material: NodeMaterial): void;
  60961. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60962. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  60963. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60964. private _injectVertexCode;
  60965. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60966. serialize(): any;
  60967. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60968. }
  60969. }
  60970. declare module BABYLON {
  60971. /**
  60972. * Block used to read a reflection texture from a sampler
  60973. */
  60974. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  60975. /**
  60976. * Create a new ReflectionTextureBlock
  60977. * @param name defines the block name
  60978. */
  60979. constructor(name: string);
  60980. /**
  60981. * Gets the current class name
  60982. * @returns the class name
  60983. */
  60984. getClassName(): string;
  60985. /**
  60986. * Gets the world position input component
  60987. */
  60988. get position(): NodeMaterialConnectionPoint;
  60989. /**
  60990. * Gets the world position input component
  60991. */
  60992. get worldPosition(): NodeMaterialConnectionPoint;
  60993. /**
  60994. * Gets the world normal input component
  60995. */
  60996. get worldNormal(): NodeMaterialConnectionPoint;
  60997. /**
  60998. * Gets the world input component
  60999. */
  61000. get world(): NodeMaterialConnectionPoint;
  61001. /**
  61002. * Gets the camera (or eye) position component
  61003. */
  61004. get cameraPosition(): NodeMaterialConnectionPoint;
  61005. /**
  61006. * Gets the view input component
  61007. */
  61008. get view(): NodeMaterialConnectionPoint;
  61009. /**
  61010. * Gets the rgb output component
  61011. */
  61012. get rgb(): NodeMaterialConnectionPoint;
  61013. /**
  61014. * Gets the r output component
  61015. */
  61016. get r(): NodeMaterialConnectionPoint;
  61017. /**
  61018. * Gets the g output component
  61019. */
  61020. get g(): NodeMaterialConnectionPoint;
  61021. /**
  61022. * Gets the b output component
  61023. */
  61024. get b(): NodeMaterialConnectionPoint;
  61025. autoConfigure(material: NodeMaterial): void;
  61026. protected _buildBlock(state: NodeMaterialBuildState): this;
  61027. }
  61028. }
  61029. declare module BABYLON {
  61030. /**
  61031. * Block used to add 2 vectors
  61032. */
  61033. export class AddBlock extends NodeMaterialBlock {
  61034. /**
  61035. * Creates a new AddBlock
  61036. * @param name defines the block name
  61037. */
  61038. constructor(name: string);
  61039. /**
  61040. * Gets the current class name
  61041. * @returns the class name
  61042. */
  61043. getClassName(): string;
  61044. /**
  61045. * Gets the left operand input component
  61046. */
  61047. get left(): NodeMaterialConnectionPoint;
  61048. /**
  61049. * Gets the right operand input component
  61050. */
  61051. get right(): NodeMaterialConnectionPoint;
  61052. /**
  61053. * Gets the output component
  61054. */
  61055. get output(): NodeMaterialConnectionPoint;
  61056. protected _buildBlock(state: NodeMaterialBuildState): this;
  61057. }
  61058. }
  61059. declare module BABYLON {
  61060. /**
  61061. * Block used to scale a vector by a float
  61062. */
  61063. export class ScaleBlock extends NodeMaterialBlock {
  61064. /**
  61065. * Creates a new ScaleBlock
  61066. * @param name defines the block name
  61067. */
  61068. constructor(name: string);
  61069. /**
  61070. * Gets the current class name
  61071. * @returns the class name
  61072. */
  61073. getClassName(): string;
  61074. /**
  61075. * Gets the input component
  61076. */
  61077. get input(): NodeMaterialConnectionPoint;
  61078. /**
  61079. * Gets the factor input component
  61080. */
  61081. get factor(): NodeMaterialConnectionPoint;
  61082. /**
  61083. * Gets the output component
  61084. */
  61085. get output(): NodeMaterialConnectionPoint;
  61086. protected _buildBlock(state: NodeMaterialBuildState): this;
  61087. }
  61088. }
  61089. declare module BABYLON {
  61090. /**
  61091. * Block used to clamp a float
  61092. */
  61093. export class ClampBlock extends NodeMaterialBlock {
  61094. /** Gets or sets the minimum range */
  61095. minimum: number;
  61096. /** Gets or sets the maximum range */
  61097. maximum: number;
  61098. /**
  61099. * Creates a new ClampBlock
  61100. * @param name defines the block name
  61101. */
  61102. constructor(name: string);
  61103. /**
  61104. * Gets the current class name
  61105. * @returns the class name
  61106. */
  61107. getClassName(): string;
  61108. /**
  61109. * Gets the value input component
  61110. */
  61111. get value(): NodeMaterialConnectionPoint;
  61112. /**
  61113. * Gets the output component
  61114. */
  61115. get output(): NodeMaterialConnectionPoint;
  61116. protected _buildBlock(state: NodeMaterialBuildState): this;
  61117. protected _dumpPropertiesCode(): string;
  61118. serialize(): any;
  61119. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61120. }
  61121. }
  61122. declare module BABYLON {
  61123. /**
  61124. * Block used to apply a cross product between 2 vectors
  61125. */
  61126. export class CrossBlock extends NodeMaterialBlock {
  61127. /**
  61128. * Creates a new CrossBlock
  61129. * @param name defines the block name
  61130. */
  61131. constructor(name: string);
  61132. /**
  61133. * Gets the current class name
  61134. * @returns the class name
  61135. */
  61136. getClassName(): string;
  61137. /**
  61138. * Gets the left operand input component
  61139. */
  61140. get left(): NodeMaterialConnectionPoint;
  61141. /**
  61142. * Gets the right operand input component
  61143. */
  61144. get right(): NodeMaterialConnectionPoint;
  61145. /**
  61146. * Gets the output component
  61147. */
  61148. get output(): NodeMaterialConnectionPoint;
  61149. protected _buildBlock(state: NodeMaterialBuildState): this;
  61150. }
  61151. }
  61152. declare module BABYLON {
  61153. /**
  61154. * Block used to apply a dot product between 2 vectors
  61155. */
  61156. export class DotBlock extends NodeMaterialBlock {
  61157. /**
  61158. * Creates a new DotBlock
  61159. * @param name defines the block name
  61160. */
  61161. constructor(name: string);
  61162. /**
  61163. * Gets the current class name
  61164. * @returns the class name
  61165. */
  61166. getClassName(): string;
  61167. /**
  61168. * Gets the left operand input component
  61169. */
  61170. get left(): NodeMaterialConnectionPoint;
  61171. /**
  61172. * Gets the right operand input component
  61173. */
  61174. get right(): NodeMaterialConnectionPoint;
  61175. /**
  61176. * Gets the output component
  61177. */
  61178. get output(): NodeMaterialConnectionPoint;
  61179. protected _buildBlock(state: NodeMaterialBuildState): this;
  61180. }
  61181. }
  61182. declare module BABYLON {
  61183. /**
  61184. * Block used to normalize a vector
  61185. */
  61186. export class NormalizeBlock extends NodeMaterialBlock {
  61187. /**
  61188. * Creates a new NormalizeBlock
  61189. * @param name defines the block name
  61190. */
  61191. constructor(name: string);
  61192. /**
  61193. * Gets the current class name
  61194. * @returns the class name
  61195. */
  61196. getClassName(): string;
  61197. /**
  61198. * Gets the input component
  61199. */
  61200. get input(): NodeMaterialConnectionPoint;
  61201. /**
  61202. * Gets the output component
  61203. */
  61204. get output(): NodeMaterialConnectionPoint;
  61205. protected _buildBlock(state: NodeMaterialBuildState): this;
  61206. }
  61207. }
  61208. declare module BABYLON {
  61209. /**
  61210. * Operations supported by the Trigonometry block
  61211. */
  61212. export enum TrigonometryBlockOperations {
  61213. /** Cos */
  61214. Cos = 0,
  61215. /** Sin */
  61216. Sin = 1,
  61217. /** Abs */
  61218. Abs = 2,
  61219. /** Exp */
  61220. Exp = 3,
  61221. /** Exp2 */
  61222. Exp2 = 4,
  61223. /** Round */
  61224. Round = 5,
  61225. /** Floor */
  61226. Floor = 6,
  61227. /** Ceiling */
  61228. Ceiling = 7,
  61229. /** Square root */
  61230. Sqrt = 8,
  61231. /** Log */
  61232. Log = 9,
  61233. /** Tangent */
  61234. Tan = 10,
  61235. /** Arc tangent */
  61236. ArcTan = 11,
  61237. /** Arc cosinus */
  61238. ArcCos = 12,
  61239. /** Arc sinus */
  61240. ArcSin = 13,
  61241. /** Fraction */
  61242. Fract = 14,
  61243. /** Sign */
  61244. Sign = 15,
  61245. /** To radians (from degrees) */
  61246. Radians = 16,
  61247. /** To degrees (from radians) */
  61248. Degrees = 17
  61249. }
  61250. /**
  61251. * Block used to apply trigonometry operation to floats
  61252. */
  61253. export class TrigonometryBlock extends NodeMaterialBlock {
  61254. /**
  61255. * Gets or sets the operation applied by the block
  61256. */
  61257. operation: TrigonometryBlockOperations;
  61258. /**
  61259. * Creates a new TrigonometryBlock
  61260. * @param name defines the block name
  61261. */
  61262. constructor(name: string);
  61263. /**
  61264. * Gets the current class name
  61265. * @returns the class name
  61266. */
  61267. getClassName(): string;
  61268. /**
  61269. * Gets the input component
  61270. */
  61271. get input(): NodeMaterialConnectionPoint;
  61272. /**
  61273. * Gets the output component
  61274. */
  61275. get output(): NodeMaterialConnectionPoint;
  61276. protected _buildBlock(state: NodeMaterialBuildState): this;
  61277. serialize(): any;
  61278. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61279. protected _dumpPropertiesCode(): string;
  61280. }
  61281. }
  61282. declare module BABYLON {
  61283. /**
  61284. * Block used to create a Color3/4 out of individual inputs (one for each component)
  61285. */
  61286. export class ColorMergerBlock extends NodeMaterialBlock {
  61287. /**
  61288. * Create a new ColorMergerBlock
  61289. * @param name defines the block name
  61290. */
  61291. constructor(name: string);
  61292. /**
  61293. * Gets the current class name
  61294. * @returns the class name
  61295. */
  61296. getClassName(): string;
  61297. /**
  61298. * Gets the rgb component (input)
  61299. */
  61300. get rgbIn(): NodeMaterialConnectionPoint;
  61301. /**
  61302. * Gets the r component (input)
  61303. */
  61304. get r(): NodeMaterialConnectionPoint;
  61305. /**
  61306. * Gets the g component (input)
  61307. */
  61308. get g(): NodeMaterialConnectionPoint;
  61309. /**
  61310. * Gets the b component (input)
  61311. */
  61312. get b(): NodeMaterialConnectionPoint;
  61313. /**
  61314. * Gets the a component (input)
  61315. */
  61316. get a(): NodeMaterialConnectionPoint;
  61317. /**
  61318. * Gets the rgba component (output)
  61319. */
  61320. get rgba(): NodeMaterialConnectionPoint;
  61321. /**
  61322. * Gets the rgb component (output)
  61323. */
  61324. get rgbOut(): NodeMaterialConnectionPoint;
  61325. /**
  61326. * Gets the rgb component (output)
  61327. * @deprecated Please use rgbOut instead.
  61328. */
  61329. get rgb(): NodeMaterialConnectionPoint;
  61330. protected _buildBlock(state: NodeMaterialBuildState): this;
  61331. }
  61332. }
  61333. declare module BABYLON {
  61334. /**
  61335. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  61336. */
  61337. export class VectorSplitterBlock extends NodeMaterialBlock {
  61338. /**
  61339. * Create a new VectorSplitterBlock
  61340. * @param name defines the block name
  61341. */
  61342. constructor(name: string);
  61343. /**
  61344. * Gets the current class name
  61345. * @returns the class name
  61346. */
  61347. getClassName(): string;
  61348. /**
  61349. * Gets the xyzw component (input)
  61350. */
  61351. get xyzw(): NodeMaterialConnectionPoint;
  61352. /**
  61353. * Gets the xyz component (input)
  61354. */
  61355. get xyzIn(): NodeMaterialConnectionPoint;
  61356. /**
  61357. * Gets the xy component (input)
  61358. */
  61359. get xyIn(): NodeMaterialConnectionPoint;
  61360. /**
  61361. * Gets the xyz component (output)
  61362. */
  61363. get xyzOut(): NodeMaterialConnectionPoint;
  61364. /**
  61365. * Gets the xy component (output)
  61366. */
  61367. get xyOut(): NodeMaterialConnectionPoint;
  61368. /**
  61369. * Gets the x component (output)
  61370. */
  61371. get x(): NodeMaterialConnectionPoint;
  61372. /**
  61373. * Gets the y component (output)
  61374. */
  61375. get y(): NodeMaterialConnectionPoint;
  61376. /**
  61377. * Gets the z component (output)
  61378. */
  61379. get z(): NodeMaterialConnectionPoint;
  61380. /**
  61381. * Gets the w component (output)
  61382. */
  61383. get w(): NodeMaterialConnectionPoint;
  61384. protected _inputRename(name: string): string;
  61385. protected _outputRename(name: string): string;
  61386. protected _buildBlock(state: NodeMaterialBuildState): this;
  61387. }
  61388. }
  61389. declare module BABYLON {
  61390. /**
  61391. * Block used to lerp between 2 values
  61392. */
  61393. export class LerpBlock extends NodeMaterialBlock {
  61394. /**
  61395. * Creates a new LerpBlock
  61396. * @param name defines the block name
  61397. */
  61398. constructor(name: string);
  61399. /**
  61400. * Gets the current class name
  61401. * @returns the class name
  61402. */
  61403. getClassName(): string;
  61404. /**
  61405. * Gets the left operand input component
  61406. */
  61407. get left(): NodeMaterialConnectionPoint;
  61408. /**
  61409. * Gets the right operand input component
  61410. */
  61411. get right(): NodeMaterialConnectionPoint;
  61412. /**
  61413. * Gets the gradient operand input component
  61414. */
  61415. get gradient(): NodeMaterialConnectionPoint;
  61416. /**
  61417. * Gets the output component
  61418. */
  61419. get output(): NodeMaterialConnectionPoint;
  61420. protected _buildBlock(state: NodeMaterialBuildState): this;
  61421. }
  61422. }
  61423. declare module BABYLON {
  61424. /**
  61425. * Block used to divide 2 vectors
  61426. */
  61427. export class DivideBlock extends NodeMaterialBlock {
  61428. /**
  61429. * Creates a new DivideBlock
  61430. * @param name defines the block name
  61431. */
  61432. constructor(name: string);
  61433. /**
  61434. * Gets the current class name
  61435. * @returns the class name
  61436. */
  61437. getClassName(): string;
  61438. /**
  61439. * Gets the left operand input component
  61440. */
  61441. get left(): NodeMaterialConnectionPoint;
  61442. /**
  61443. * Gets the right operand input component
  61444. */
  61445. get right(): NodeMaterialConnectionPoint;
  61446. /**
  61447. * Gets the output component
  61448. */
  61449. get output(): NodeMaterialConnectionPoint;
  61450. protected _buildBlock(state: NodeMaterialBuildState): this;
  61451. }
  61452. }
  61453. declare module BABYLON {
  61454. /**
  61455. * Block used to subtract 2 vectors
  61456. */
  61457. export class SubtractBlock extends NodeMaterialBlock {
  61458. /**
  61459. * Creates a new SubtractBlock
  61460. * @param name defines the block name
  61461. */
  61462. constructor(name: string);
  61463. /**
  61464. * Gets the current class name
  61465. * @returns the class name
  61466. */
  61467. getClassName(): string;
  61468. /**
  61469. * Gets the left operand input component
  61470. */
  61471. get left(): NodeMaterialConnectionPoint;
  61472. /**
  61473. * Gets the right operand input component
  61474. */
  61475. get right(): NodeMaterialConnectionPoint;
  61476. /**
  61477. * Gets the output component
  61478. */
  61479. get output(): NodeMaterialConnectionPoint;
  61480. protected _buildBlock(state: NodeMaterialBuildState): this;
  61481. }
  61482. }
  61483. declare module BABYLON {
  61484. /**
  61485. * Block used to step a value
  61486. */
  61487. export class StepBlock extends NodeMaterialBlock {
  61488. /**
  61489. * Creates a new StepBlock
  61490. * @param name defines the block name
  61491. */
  61492. constructor(name: string);
  61493. /**
  61494. * Gets the current class name
  61495. * @returns the class name
  61496. */
  61497. getClassName(): string;
  61498. /**
  61499. * Gets the value operand input component
  61500. */
  61501. get value(): NodeMaterialConnectionPoint;
  61502. /**
  61503. * Gets the edge operand input component
  61504. */
  61505. get edge(): NodeMaterialConnectionPoint;
  61506. /**
  61507. * Gets the output component
  61508. */
  61509. get output(): NodeMaterialConnectionPoint;
  61510. protected _buildBlock(state: NodeMaterialBuildState): this;
  61511. }
  61512. }
  61513. declare module BABYLON {
  61514. /**
  61515. * Block used to get the opposite (1 - x) of a value
  61516. */
  61517. export class OneMinusBlock extends NodeMaterialBlock {
  61518. /**
  61519. * Creates a new OneMinusBlock
  61520. * @param name defines the block name
  61521. */
  61522. constructor(name: string);
  61523. /**
  61524. * Gets the current class name
  61525. * @returns the class name
  61526. */
  61527. getClassName(): string;
  61528. /**
  61529. * Gets the input component
  61530. */
  61531. get input(): NodeMaterialConnectionPoint;
  61532. /**
  61533. * Gets the output component
  61534. */
  61535. get output(): NodeMaterialConnectionPoint;
  61536. protected _buildBlock(state: NodeMaterialBuildState): this;
  61537. }
  61538. }
  61539. declare module BABYLON {
  61540. /**
  61541. * Block used to get the view direction
  61542. */
  61543. export class ViewDirectionBlock extends NodeMaterialBlock {
  61544. /**
  61545. * Creates a new ViewDirectionBlock
  61546. * @param name defines the block name
  61547. */
  61548. constructor(name: string);
  61549. /**
  61550. * Gets the current class name
  61551. * @returns the class name
  61552. */
  61553. getClassName(): string;
  61554. /**
  61555. * Gets the world position component
  61556. */
  61557. get worldPosition(): NodeMaterialConnectionPoint;
  61558. /**
  61559. * Gets the camera position component
  61560. */
  61561. get cameraPosition(): NodeMaterialConnectionPoint;
  61562. /**
  61563. * Gets the output component
  61564. */
  61565. get output(): NodeMaterialConnectionPoint;
  61566. autoConfigure(material: NodeMaterial): void;
  61567. protected _buildBlock(state: NodeMaterialBuildState): this;
  61568. }
  61569. }
  61570. declare module BABYLON {
  61571. /**
  61572. * Block used to compute fresnel value
  61573. */
  61574. export class FresnelBlock extends NodeMaterialBlock {
  61575. /**
  61576. * Create a new FresnelBlock
  61577. * @param name defines the block name
  61578. */
  61579. constructor(name: string);
  61580. /**
  61581. * Gets the current class name
  61582. * @returns the class name
  61583. */
  61584. getClassName(): string;
  61585. /**
  61586. * Gets the world normal input component
  61587. */
  61588. get worldNormal(): NodeMaterialConnectionPoint;
  61589. /**
  61590. * Gets the view direction input component
  61591. */
  61592. get viewDirection(): NodeMaterialConnectionPoint;
  61593. /**
  61594. * Gets the bias input component
  61595. */
  61596. get bias(): NodeMaterialConnectionPoint;
  61597. /**
  61598. * Gets the camera (or eye) position component
  61599. */
  61600. get power(): NodeMaterialConnectionPoint;
  61601. /**
  61602. * Gets the fresnel output component
  61603. */
  61604. get fresnel(): NodeMaterialConnectionPoint;
  61605. autoConfigure(material: NodeMaterial): void;
  61606. protected _buildBlock(state: NodeMaterialBuildState): this;
  61607. }
  61608. }
  61609. declare module BABYLON {
  61610. /**
  61611. * Block used to get the max of 2 values
  61612. */
  61613. export class MaxBlock extends NodeMaterialBlock {
  61614. /**
  61615. * Creates a new MaxBlock
  61616. * @param name defines the block name
  61617. */
  61618. constructor(name: string);
  61619. /**
  61620. * Gets the current class name
  61621. * @returns the class name
  61622. */
  61623. getClassName(): string;
  61624. /**
  61625. * Gets the left operand input component
  61626. */
  61627. get left(): NodeMaterialConnectionPoint;
  61628. /**
  61629. * Gets the right operand input component
  61630. */
  61631. get right(): NodeMaterialConnectionPoint;
  61632. /**
  61633. * Gets the output component
  61634. */
  61635. get output(): NodeMaterialConnectionPoint;
  61636. protected _buildBlock(state: NodeMaterialBuildState): this;
  61637. }
  61638. }
  61639. declare module BABYLON {
  61640. /**
  61641. * Block used to get the min of 2 values
  61642. */
  61643. export class MinBlock extends NodeMaterialBlock {
  61644. /**
  61645. * Creates a new MinBlock
  61646. * @param name defines the block name
  61647. */
  61648. constructor(name: string);
  61649. /**
  61650. * Gets the current class name
  61651. * @returns the class name
  61652. */
  61653. getClassName(): string;
  61654. /**
  61655. * Gets the left operand input component
  61656. */
  61657. get left(): NodeMaterialConnectionPoint;
  61658. /**
  61659. * Gets the right operand input component
  61660. */
  61661. get right(): NodeMaterialConnectionPoint;
  61662. /**
  61663. * Gets the output component
  61664. */
  61665. get output(): NodeMaterialConnectionPoint;
  61666. protected _buildBlock(state: NodeMaterialBuildState): this;
  61667. }
  61668. }
  61669. declare module BABYLON {
  61670. /**
  61671. * Block used to get the distance between 2 values
  61672. */
  61673. export class DistanceBlock extends NodeMaterialBlock {
  61674. /**
  61675. * Creates a new DistanceBlock
  61676. * @param name defines the block name
  61677. */
  61678. constructor(name: string);
  61679. /**
  61680. * Gets the current class name
  61681. * @returns the class name
  61682. */
  61683. getClassName(): string;
  61684. /**
  61685. * Gets the left operand input component
  61686. */
  61687. get left(): NodeMaterialConnectionPoint;
  61688. /**
  61689. * Gets the right operand input component
  61690. */
  61691. get right(): NodeMaterialConnectionPoint;
  61692. /**
  61693. * Gets the output component
  61694. */
  61695. get output(): NodeMaterialConnectionPoint;
  61696. protected _buildBlock(state: NodeMaterialBuildState): this;
  61697. }
  61698. }
  61699. declare module BABYLON {
  61700. /**
  61701. * Block used to get the length of a vector
  61702. */
  61703. export class LengthBlock extends NodeMaterialBlock {
  61704. /**
  61705. * Creates a new LengthBlock
  61706. * @param name defines the block name
  61707. */
  61708. constructor(name: string);
  61709. /**
  61710. * Gets the current class name
  61711. * @returns the class name
  61712. */
  61713. getClassName(): string;
  61714. /**
  61715. * Gets the value input component
  61716. */
  61717. get value(): NodeMaterialConnectionPoint;
  61718. /**
  61719. * Gets the output component
  61720. */
  61721. get output(): NodeMaterialConnectionPoint;
  61722. protected _buildBlock(state: NodeMaterialBuildState): this;
  61723. }
  61724. }
  61725. declare module BABYLON {
  61726. /**
  61727. * Block used to get negative version of a value (i.e. x * -1)
  61728. */
  61729. export class NegateBlock extends NodeMaterialBlock {
  61730. /**
  61731. * Creates a new NegateBlock
  61732. * @param name defines the block name
  61733. */
  61734. constructor(name: string);
  61735. /**
  61736. * Gets the current class name
  61737. * @returns the class name
  61738. */
  61739. getClassName(): string;
  61740. /**
  61741. * Gets the value input component
  61742. */
  61743. get value(): NodeMaterialConnectionPoint;
  61744. /**
  61745. * Gets the output component
  61746. */
  61747. get output(): NodeMaterialConnectionPoint;
  61748. protected _buildBlock(state: NodeMaterialBuildState): this;
  61749. }
  61750. }
  61751. declare module BABYLON {
  61752. /**
  61753. * Block used to get the value of the first parameter raised to the power of the second
  61754. */
  61755. export class PowBlock extends NodeMaterialBlock {
  61756. /**
  61757. * Creates a new PowBlock
  61758. * @param name defines the block name
  61759. */
  61760. constructor(name: string);
  61761. /**
  61762. * Gets the current class name
  61763. * @returns the class name
  61764. */
  61765. getClassName(): string;
  61766. /**
  61767. * Gets the value operand input component
  61768. */
  61769. get value(): NodeMaterialConnectionPoint;
  61770. /**
  61771. * Gets the power operand input component
  61772. */
  61773. get power(): NodeMaterialConnectionPoint;
  61774. /**
  61775. * Gets the output component
  61776. */
  61777. get output(): NodeMaterialConnectionPoint;
  61778. protected _buildBlock(state: NodeMaterialBuildState): this;
  61779. }
  61780. }
  61781. declare module BABYLON {
  61782. /**
  61783. * Block used to get a random number
  61784. */
  61785. export class RandomNumberBlock extends NodeMaterialBlock {
  61786. /**
  61787. * Creates a new RandomNumberBlock
  61788. * @param name defines the block name
  61789. */
  61790. constructor(name: string);
  61791. /**
  61792. * Gets the current class name
  61793. * @returns the class name
  61794. */
  61795. getClassName(): string;
  61796. /**
  61797. * Gets the seed input component
  61798. */
  61799. get seed(): NodeMaterialConnectionPoint;
  61800. /**
  61801. * Gets the output component
  61802. */
  61803. get output(): NodeMaterialConnectionPoint;
  61804. protected _buildBlock(state: NodeMaterialBuildState): this;
  61805. }
  61806. }
  61807. declare module BABYLON {
  61808. /**
  61809. * Block used to compute arc tangent of 2 values
  61810. */
  61811. export class ArcTan2Block extends NodeMaterialBlock {
  61812. /**
  61813. * Creates a new ArcTan2Block
  61814. * @param name defines the block name
  61815. */
  61816. constructor(name: string);
  61817. /**
  61818. * Gets the current class name
  61819. * @returns the class name
  61820. */
  61821. getClassName(): string;
  61822. /**
  61823. * Gets the x operand input component
  61824. */
  61825. get x(): NodeMaterialConnectionPoint;
  61826. /**
  61827. * Gets the y operand input component
  61828. */
  61829. get y(): NodeMaterialConnectionPoint;
  61830. /**
  61831. * Gets the output component
  61832. */
  61833. get output(): NodeMaterialConnectionPoint;
  61834. protected _buildBlock(state: NodeMaterialBuildState): this;
  61835. }
  61836. }
  61837. declare module BABYLON {
  61838. /**
  61839. * Block used to smooth step a value
  61840. */
  61841. export class SmoothStepBlock extends NodeMaterialBlock {
  61842. /**
  61843. * Creates a new SmoothStepBlock
  61844. * @param name defines the block name
  61845. */
  61846. constructor(name: string);
  61847. /**
  61848. * Gets the current class name
  61849. * @returns the class name
  61850. */
  61851. getClassName(): string;
  61852. /**
  61853. * Gets the value operand input component
  61854. */
  61855. get value(): NodeMaterialConnectionPoint;
  61856. /**
  61857. * Gets the first edge operand input component
  61858. */
  61859. get edge0(): NodeMaterialConnectionPoint;
  61860. /**
  61861. * Gets the second edge operand input component
  61862. */
  61863. get edge1(): NodeMaterialConnectionPoint;
  61864. /**
  61865. * Gets the output component
  61866. */
  61867. get output(): NodeMaterialConnectionPoint;
  61868. protected _buildBlock(state: NodeMaterialBuildState): this;
  61869. }
  61870. }
  61871. declare module BABYLON {
  61872. /**
  61873. * Block used to get the reciprocal (1 / x) of a value
  61874. */
  61875. export class ReciprocalBlock extends NodeMaterialBlock {
  61876. /**
  61877. * Creates a new ReciprocalBlock
  61878. * @param name defines the block name
  61879. */
  61880. constructor(name: string);
  61881. /**
  61882. * Gets the current class name
  61883. * @returns the class name
  61884. */
  61885. getClassName(): string;
  61886. /**
  61887. * Gets the input component
  61888. */
  61889. get input(): NodeMaterialConnectionPoint;
  61890. /**
  61891. * Gets the output component
  61892. */
  61893. get output(): NodeMaterialConnectionPoint;
  61894. protected _buildBlock(state: NodeMaterialBuildState): this;
  61895. }
  61896. }
  61897. declare module BABYLON {
  61898. /**
  61899. * Block used to replace a color by another one
  61900. */
  61901. export class ReplaceColorBlock extends NodeMaterialBlock {
  61902. /**
  61903. * Creates a new ReplaceColorBlock
  61904. * @param name defines the block name
  61905. */
  61906. constructor(name: string);
  61907. /**
  61908. * Gets the current class name
  61909. * @returns the class name
  61910. */
  61911. getClassName(): string;
  61912. /**
  61913. * Gets the value input component
  61914. */
  61915. get value(): NodeMaterialConnectionPoint;
  61916. /**
  61917. * Gets the reference input component
  61918. */
  61919. get reference(): NodeMaterialConnectionPoint;
  61920. /**
  61921. * Gets the distance input component
  61922. */
  61923. get distance(): NodeMaterialConnectionPoint;
  61924. /**
  61925. * Gets the replacement input component
  61926. */
  61927. get replacement(): NodeMaterialConnectionPoint;
  61928. /**
  61929. * Gets the output component
  61930. */
  61931. get output(): NodeMaterialConnectionPoint;
  61932. protected _buildBlock(state: NodeMaterialBuildState): this;
  61933. }
  61934. }
  61935. declare module BABYLON {
  61936. /**
  61937. * Block used to posterize a value
  61938. * @see https://en.wikipedia.org/wiki/Posterization
  61939. */
  61940. export class PosterizeBlock extends NodeMaterialBlock {
  61941. /**
  61942. * Creates a new PosterizeBlock
  61943. * @param name defines the block name
  61944. */
  61945. constructor(name: string);
  61946. /**
  61947. * Gets the current class name
  61948. * @returns the class name
  61949. */
  61950. getClassName(): string;
  61951. /**
  61952. * Gets the value input component
  61953. */
  61954. get value(): NodeMaterialConnectionPoint;
  61955. /**
  61956. * Gets the steps input component
  61957. */
  61958. get steps(): NodeMaterialConnectionPoint;
  61959. /**
  61960. * Gets the output component
  61961. */
  61962. get output(): NodeMaterialConnectionPoint;
  61963. protected _buildBlock(state: NodeMaterialBuildState): this;
  61964. }
  61965. }
  61966. declare module BABYLON {
  61967. /**
  61968. * Operations supported by the Wave block
  61969. */
  61970. export enum WaveBlockKind {
  61971. /** SawTooth */
  61972. SawTooth = 0,
  61973. /** Square */
  61974. Square = 1,
  61975. /** Triangle */
  61976. Triangle = 2
  61977. }
  61978. /**
  61979. * Block used to apply wave operation to floats
  61980. */
  61981. export class WaveBlock extends NodeMaterialBlock {
  61982. /**
  61983. * Gets or sets the kibnd of wave to be applied by the block
  61984. */
  61985. kind: WaveBlockKind;
  61986. /**
  61987. * Creates a new WaveBlock
  61988. * @param name defines the block name
  61989. */
  61990. constructor(name: string);
  61991. /**
  61992. * Gets the current class name
  61993. * @returns the class name
  61994. */
  61995. getClassName(): string;
  61996. /**
  61997. * Gets the input component
  61998. */
  61999. get input(): NodeMaterialConnectionPoint;
  62000. /**
  62001. * Gets the output component
  62002. */
  62003. get output(): NodeMaterialConnectionPoint;
  62004. protected _buildBlock(state: NodeMaterialBuildState): this;
  62005. serialize(): any;
  62006. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62007. }
  62008. }
  62009. declare module BABYLON {
  62010. /**
  62011. * Class used to store a color step for the GradientBlock
  62012. */
  62013. export class GradientBlockColorStep {
  62014. /**
  62015. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62016. */
  62017. step: number;
  62018. /**
  62019. * Gets or sets the color associated with this step
  62020. */
  62021. color: Color3;
  62022. /**
  62023. * Creates a new GradientBlockColorStep
  62024. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62025. * @param color defines the color associated with this step
  62026. */
  62027. constructor(
  62028. /**
  62029. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62030. */
  62031. step: number,
  62032. /**
  62033. * Gets or sets the color associated with this step
  62034. */
  62035. color: Color3);
  62036. }
  62037. /**
  62038. * Block used to return a color from a gradient based on an input value between 0 and 1
  62039. */
  62040. export class GradientBlock extends NodeMaterialBlock {
  62041. /**
  62042. * Gets or sets the list of color steps
  62043. */
  62044. colorSteps: GradientBlockColorStep[];
  62045. /**
  62046. * Creates a new GradientBlock
  62047. * @param name defines the block name
  62048. */
  62049. constructor(name: string);
  62050. /**
  62051. * Gets the current class name
  62052. * @returns the class name
  62053. */
  62054. getClassName(): string;
  62055. /**
  62056. * Gets the gradient input component
  62057. */
  62058. get gradient(): NodeMaterialConnectionPoint;
  62059. /**
  62060. * Gets the output component
  62061. */
  62062. get output(): NodeMaterialConnectionPoint;
  62063. private _writeColorConstant;
  62064. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62065. serialize(): any;
  62066. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62067. protected _dumpPropertiesCode(): string;
  62068. }
  62069. }
  62070. declare module BABYLON {
  62071. /**
  62072. * Block used to normalize lerp between 2 values
  62073. */
  62074. export class NLerpBlock extends NodeMaterialBlock {
  62075. /**
  62076. * Creates a new NLerpBlock
  62077. * @param name defines the block name
  62078. */
  62079. constructor(name: string);
  62080. /**
  62081. * Gets the current class name
  62082. * @returns the class name
  62083. */
  62084. getClassName(): string;
  62085. /**
  62086. * Gets the left operand input component
  62087. */
  62088. get left(): NodeMaterialConnectionPoint;
  62089. /**
  62090. * Gets the right operand input component
  62091. */
  62092. get right(): NodeMaterialConnectionPoint;
  62093. /**
  62094. * Gets the gradient operand input component
  62095. */
  62096. get gradient(): NodeMaterialConnectionPoint;
  62097. /**
  62098. * Gets the output component
  62099. */
  62100. get output(): NodeMaterialConnectionPoint;
  62101. protected _buildBlock(state: NodeMaterialBuildState): this;
  62102. }
  62103. }
  62104. declare module BABYLON {
  62105. /**
  62106. * block used to Generate a Worley Noise 3D Noise Pattern
  62107. */
  62108. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62109. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62110. manhattanDistance: boolean;
  62111. /**
  62112. * Creates a new WorleyNoise3DBlock
  62113. * @param name defines the block name
  62114. */
  62115. constructor(name: string);
  62116. /**
  62117. * Gets the current class name
  62118. * @returns the class name
  62119. */
  62120. getClassName(): string;
  62121. /**
  62122. * Gets the seed input component
  62123. */
  62124. get seed(): NodeMaterialConnectionPoint;
  62125. /**
  62126. * Gets the jitter input component
  62127. */
  62128. get jitter(): NodeMaterialConnectionPoint;
  62129. /**
  62130. * Gets the output component
  62131. */
  62132. get output(): NodeMaterialConnectionPoint;
  62133. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62134. /**
  62135. * Exposes the properties to the UI?
  62136. */
  62137. protected _dumpPropertiesCode(): string;
  62138. /**
  62139. * Exposes the properties to the Seralize?
  62140. */
  62141. serialize(): any;
  62142. /**
  62143. * Exposes the properties to the deseralize?
  62144. */
  62145. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62146. }
  62147. }
  62148. declare module BABYLON {
  62149. /**
  62150. * block used to Generate a Simplex Perlin 3d Noise Pattern
  62151. */
  62152. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  62153. /**
  62154. * Creates a new SimplexPerlin3DBlock
  62155. * @param name defines the block name
  62156. */
  62157. constructor(name: string);
  62158. /**
  62159. * Gets the current class name
  62160. * @returns the class name
  62161. */
  62162. getClassName(): string;
  62163. /**
  62164. * Gets the seed operand input component
  62165. */
  62166. get seed(): NodeMaterialConnectionPoint;
  62167. /**
  62168. * Gets the output component
  62169. */
  62170. get output(): NodeMaterialConnectionPoint;
  62171. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62172. }
  62173. }
  62174. declare module BABYLON {
  62175. /**
  62176. * Block used to blend normals
  62177. */
  62178. export class NormalBlendBlock extends NodeMaterialBlock {
  62179. /**
  62180. * Creates a new NormalBlendBlock
  62181. * @param name defines the block name
  62182. */
  62183. constructor(name: string);
  62184. /**
  62185. * Gets the current class name
  62186. * @returns the class name
  62187. */
  62188. getClassName(): string;
  62189. /**
  62190. * Gets the first input component
  62191. */
  62192. get normalMap0(): NodeMaterialConnectionPoint;
  62193. /**
  62194. * Gets the second input component
  62195. */
  62196. get normalMap1(): NodeMaterialConnectionPoint;
  62197. /**
  62198. * Gets the output component
  62199. */
  62200. get output(): NodeMaterialConnectionPoint;
  62201. protected _buildBlock(state: NodeMaterialBuildState): this;
  62202. }
  62203. }
  62204. declare module BABYLON {
  62205. /**
  62206. * Block used to rotate a 2d vector by a given angle
  62207. */
  62208. export class Rotate2dBlock extends NodeMaterialBlock {
  62209. /**
  62210. * Creates a new Rotate2dBlock
  62211. * @param name defines the block name
  62212. */
  62213. constructor(name: string);
  62214. /**
  62215. * Gets the current class name
  62216. * @returns the class name
  62217. */
  62218. getClassName(): string;
  62219. /**
  62220. * Gets the input vector
  62221. */
  62222. get input(): NodeMaterialConnectionPoint;
  62223. /**
  62224. * Gets the input angle
  62225. */
  62226. get angle(): NodeMaterialConnectionPoint;
  62227. /**
  62228. * Gets the output component
  62229. */
  62230. get output(): NodeMaterialConnectionPoint;
  62231. autoConfigure(material: NodeMaterial): void;
  62232. protected _buildBlock(state: NodeMaterialBuildState): this;
  62233. }
  62234. }
  62235. declare module BABYLON {
  62236. /**
  62237. * Block used to get the reflected vector from a direction and a normal
  62238. */
  62239. export class ReflectBlock extends NodeMaterialBlock {
  62240. /**
  62241. * Creates a new ReflectBlock
  62242. * @param name defines the block name
  62243. */
  62244. constructor(name: string);
  62245. /**
  62246. * Gets the current class name
  62247. * @returns the class name
  62248. */
  62249. getClassName(): string;
  62250. /**
  62251. * Gets the incident component
  62252. */
  62253. get incident(): NodeMaterialConnectionPoint;
  62254. /**
  62255. * Gets the normal component
  62256. */
  62257. get normal(): NodeMaterialConnectionPoint;
  62258. /**
  62259. * Gets the output component
  62260. */
  62261. get output(): NodeMaterialConnectionPoint;
  62262. protected _buildBlock(state: NodeMaterialBuildState): this;
  62263. }
  62264. }
  62265. declare module BABYLON {
  62266. /**
  62267. * Block used to get the refracted vector from a direction and a normal
  62268. */
  62269. export class RefractBlock extends NodeMaterialBlock {
  62270. /**
  62271. * Creates a new RefractBlock
  62272. * @param name defines the block name
  62273. */
  62274. constructor(name: string);
  62275. /**
  62276. * Gets the current class name
  62277. * @returns the class name
  62278. */
  62279. getClassName(): string;
  62280. /**
  62281. * Gets the incident component
  62282. */
  62283. get incident(): NodeMaterialConnectionPoint;
  62284. /**
  62285. * Gets the normal component
  62286. */
  62287. get normal(): NodeMaterialConnectionPoint;
  62288. /**
  62289. * Gets the index of refraction component
  62290. */
  62291. get ior(): NodeMaterialConnectionPoint;
  62292. /**
  62293. * Gets the output component
  62294. */
  62295. get output(): NodeMaterialConnectionPoint;
  62296. protected _buildBlock(state: NodeMaterialBuildState): this;
  62297. }
  62298. }
  62299. declare module BABYLON {
  62300. /**
  62301. * Block used to desaturate a color
  62302. */
  62303. export class DesaturateBlock extends NodeMaterialBlock {
  62304. /**
  62305. * Creates a new DesaturateBlock
  62306. * @param name defines the block name
  62307. */
  62308. constructor(name: string);
  62309. /**
  62310. * Gets the current class name
  62311. * @returns the class name
  62312. */
  62313. getClassName(): string;
  62314. /**
  62315. * Gets the color operand input component
  62316. */
  62317. get color(): NodeMaterialConnectionPoint;
  62318. /**
  62319. * Gets the level operand input component
  62320. */
  62321. get level(): NodeMaterialConnectionPoint;
  62322. /**
  62323. * Gets the output component
  62324. */
  62325. get output(): NodeMaterialConnectionPoint;
  62326. protected _buildBlock(state: NodeMaterialBuildState): this;
  62327. }
  62328. }
  62329. declare module BABYLON {
  62330. /**
  62331. * Block used to implement the ambient occlusion module of the PBR material
  62332. */
  62333. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  62334. /**
  62335. * Create a new AmbientOcclusionBlock
  62336. * @param name defines the block name
  62337. */
  62338. constructor(name: string);
  62339. /**
  62340. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  62341. */
  62342. useAmbientInGrayScale: boolean;
  62343. /**
  62344. * Initialize the block and prepare the context for build
  62345. * @param state defines the state that will be used for the build
  62346. */
  62347. initialize(state: NodeMaterialBuildState): void;
  62348. /**
  62349. * Gets the current class name
  62350. * @returns the class name
  62351. */
  62352. getClassName(): string;
  62353. /**
  62354. * Gets the texture input component
  62355. */
  62356. get texture(): NodeMaterialConnectionPoint;
  62357. /**
  62358. * Gets the texture intensity component
  62359. */
  62360. get intensity(): NodeMaterialConnectionPoint;
  62361. /**
  62362. * Gets the direct light intensity input component
  62363. */
  62364. get directLightIntensity(): NodeMaterialConnectionPoint;
  62365. /**
  62366. * Gets the ambient occlusion object output component
  62367. */
  62368. get ambientOcclusion(): NodeMaterialConnectionPoint;
  62369. /**
  62370. * Gets the main code of the block (fragment side)
  62371. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  62372. * @returns the shader code
  62373. */
  62374. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  62375. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62376. protected _buildBlock(state: NodeMaterialBuildState): this;
  62377. protected _dumpPropertiesCode(): string;
  62378. serialize(): any;
  62379. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62380. }
  62381. }
  62382. declare module BABYLON {
  62383. /**
  62384. * Block used to implement the reflection module of the PBR material
  62385. */
  62386. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  62387. /** @hidden */
  62388. _defineLODReflectionAlpha: string;
  62389. /** @hidden */
  62390. _defineLinearSpecularReflection: string;
  62391. private _vEnvironmentIrradianceName;
  62392. /** @hidden */
  62393. _vReflectionMicrosurfaceInfosName: string;
  62394. /** @hidden */
  62395. _vReflectionInfosName: string;
  62396. private _scene;
  62397. /**
  62398. * The three properties below are set by the main PBR block prior to calling methods of this class.
  62399. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  62400. * It's less burden on the user side in the editor part.
  62401. */
  62402. /** @hidden */
  62403. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  62404. /** @hidden */
  62405. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  62406. /** @hidden */
  62407. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  62408. /**
  62409. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  62410. * diffuse part of the IBL.
  62411. */
  62412. useSphericalHarmonics: boolean;
  62413. /**
  62414. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  62415. */
  62416. forceIrradianceInFragment: boolean;
  62417. /**
  62418. * Create a new ReflectionBlock
  62419. * @param name defines the block name
  62420. */
  62421. constructor(name: string);
  62422. /**
  62423. * Gets the current class name
  62424. * @returns the class name
  62425. */
  62426. getClassName(): string;
  62427. /**
  62428. * Gets the position input component
  62429. */
  62430. get position(): NodeMaterialConnectionPoint;
  62431. /**
  62432. * Gets the world position input component
  62433. */
  62434. get worldPosition(): NodeMaterialConnectionPoint;
  62435. /**
  62436. * Gets the world normal input component
  62437. */
  62438. get worldNormal(): NodeMaterialConnectionPoint;
  62439. /**
  62440. * Gets the world input component
  62441. */
  62442. get world(): NodeMaterialConnectionPoint;
  62443. /**
  62444. * Gets the camera (or eye) position component
  62445. */
  62446. get cameraPosition(): NodeMaterialConnectionPoint;
  62447. /**
  62448. * Gets the view input component
  62449. */
  62450. get view(): NodeMaterialConnectionPoint;
  62451. /**
  62452. * Gets the color input component
  62453. */
  62454. get color(): NodeMaterialConnectionPoint;
  62455. /**
  62456. * Gets the reflection object output component
  62457. */
  62458. get reflection(): NodeMaterialConnectionPoint;
  62459. /**
  62460. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  62461. */
  62462. get hasTexture(): boolean;
  62463. /**
  62464. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  62465. */
  62466. get reflectionColor(): string;
  62467. protected _getTexture(): Nullable<BaseTexture>;
  62468. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62469. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  62470. /**
  62471. * Gets the code to inject in the vertex shader
  62472. * @param state current state of the node material building
  62473. * @returns the shader code
  62474. */
  62475. handleVertexSide(state: NodeMaterialBuildState): string;
  62476. /**
  62477. * Gets the main code of the block (fragment side)
  62478. * @param state current state of the node material building
  62479. * @param normalVarName name of the existing variable corresponding to the normal
  62480. * @returns the shader code
  62481. */
  62482. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  62483. protected _buildBlock(state: NodeMaterialBuildState): this;
  62484. protected _dumpPropertiesCode(): string;
  62485. serialize(): any;
  62486. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62487. }
  62488. }
  62489. declare module BABYLON {
  62490. /**
  62491. * Block used to implement the sheen module of the PBR material
  62492. */
  62493. export class SheenBlock extends NodeMaterialBlock {
  62494. /**
  62495. * Create a new SheenBlock
  62496. * @param name defines the block name
  62497. */
  62498. constructor(name: string);
  62499. /**
  62500. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  62501. * It allows the strength of the sheen effect to not depend on the base color of the material,
  62502. * making it easier to setup and tweak the effect
  62503. */
  62504. albedoScaling: boolean;
  62505. /**
  62506. * Defines if the sheen is linked to the sheen color.
  62507. */
  62508. linkSheenWithAlbedo: boolean;
  62509. /**
  62510. * Initialize the block and prepare the context for build
  62511. * @param state defines the state that will be used for the build
  62512. */
  62513. initialize(state: NodeMaterialBuildState): void;
  62514. /**
  62515. * Gets the current class name
  62516. * @returns the class name
  62517. */
  62518. getClassName(): string;
  62519. /**
  62520. * Gets the intensity input component
  62521. */
  62522. get intensity(): NodeMaterialConnectionPoint;
  62523. /**
  62524. * Gets the color input component
  62525. */
  62526. get color(): NodeMaterialConnectionPoint;
  62527. /**
  62528. * Gets the roughness input component
  62529. */
  62530. get roughness(): NodeMaterialConnectionPoint;
  62531. /**
  62532. * Gets the texture input component
  62533. */
  62534. get texture(): NodeMaterialConnectionPoint;
  62535. /**
  62536. * Gets the sheen object output component
  62537. */
  62538. get sheen(): NodeMaterialConnectionPoint;
  62539. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62540. /**
  62541. * Gets the main code of the block (fragment side)
  62542. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  62543. * @returns the shader code
  62544. */
  62545. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  62546. protected _buildBlock(state: NodeMaterialBuildState): this;
  62547. protected _dumpPropertiesCode(): string;
  62548. serialize(): any;
  62549. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62550. }
  62551. }
  62552. declare module BABYLON {
  62553. /**
  62554. * Block used to implement the reflectivity module of the PBR material
  62555. */
  62556. export class ReflectivityBlock extends NodeMaterialBlock {
  62557. /**
  62558. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  62559. */
  62560. useAmbientOcclusionFromMetallicTextureRed: boolean;
  62561. /**
  62562. * Specifies if the metallic texture contains the metallness information in its blue channel.
  62563. */
  62564. useMetallnessFromMetallicTextureBlue: boolean;
  62565. /**
  62566. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  62567. */
  62568. useRoughnessFromMetallicTextureAlpha: boolean;
  62569. /**
  62570. * Specifies if the metallic texture contains the roughness information in its green channel.
  62571. */
  62572. useRoughnessFromMetallicTextureGreen: boolean;
  62573. /**
  62574. * Create a new ReflectivityBlock
  62575. * @param name defines the block name
  62576. */
  62577. constructor(name: string);
  62578. /**
  62579. * Initialize the block and prepare the context for build
  62580. * @param state defines the state that will be used for the build
  62581. */
  62582. initialize(state: NodeMaterialBuildState): void;
  62583. /**
  62584. * Gets the current class name
  62585. * @returns the class name
  62586. */
  62587. getClassName(): string;
  62588. /**
  62589. * Gets the metallic input component
  62590. */
  62591. get metallic(): NodeMaterialConnectionPoint;
  62592. /**
  62593. * Gets the roughness input component
  62594. */
  62595. get roughness(): NodeMaterialConnectionPoint;
  62596. /**
  62597. * Gets the texture input component
  62598. */
  62599. get texture(): NodeMaterialConnectionPoint;
  62600. /**
  62601. * Gets the reflectivity object output component
  62602. */
  62603. get reflectivity(): NodeMaterialConnectionPoint;
  62604. /**
  62605. * Gets the main code of the block (fragment side)
  62606. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  62607. * @returns the shader code
  62608. */
  62609. getCode(aoIntensityVarName: string): string;
  62610. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62611. protected _buildBlock(state: NodeMaterialBuildState): this;
  62612. protected _dumpPropertiesCode(): string;
  62613. serialize(): any;
  62614. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62615. }
  62616. }
  62617. declare module BABYLON {
  62618. /**
  62619. * Block used to implement the anisotropy module of the PBR material
  62620. */
  62621. export class AnisotropyBlock extends NodeMaterialBlock {
  62622. /**
  62623. * The two properties below are set by the main PBR block prior to calling methods of this class.
  62624. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  62625. * It's less burden on the user side in the editor part.
  62626. */
  62627. /** @hidden */
  62628. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  62629. /** @hidden */
  62630. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  62631. /**
  62632. * Create a new AnisotropyBlock
  62633. * @param name defines the block name
  62634. */
  62635. constructor(name: string);
  62636. /**
  62637. * Initialize the block and prepare the context for build
  62638. * @param state defines the state that will be used for the build
  62639. */
  62640. initialize(state: NodeMaterialBuildState): void;
  62641. /**
  62642. * Gets the current class name
  62643. * @returns the class name
  62644. */
  62645. getClassName(): string;
  62646. /**
  62647. * Gets the intensity input component
  62648. */
  62649. get intensity(): NodeMaterialConnectionPoint;
  62650. /**
  62651. * Gets the direction input component
  62652. */
  62653. get direction(): NodeMaterialConnectionPoint;
  62654. /**
  62655. * Gets the texture input component
  62656. */
  62657. get texture(): NodeMaterialConnectionPoint;
  62658. /**
  62659. * Gets the uv input component
  62660. */
  62661. get uv(): NodeMaterialConnectionPoint;
  62662. /**
  62663. * Gets the worldTangent input component
  62664. */
  62665. get worldTangent(): NodeMaterialConnectionPoint;
  62666. /**
  62667. * Gets the anisotropy object output component
  62668. */
  62669. get anisotropy(): NodeMaterialConnectionPoint;
  62670. private _generateTBNSpace;
  62671. /**
  62672. * Gets the main code of the block (fragment side)
  62673. * @param state current state of the node material building
  62674. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  62675. * @returns the shader code
  62676. */
  62677. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  62678. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62679. protected _buildBlock(state: NodeMaterialBuildState): this;
  62680. }
  62681. }
  62682. declare module BABYLON {
  62683. /**
  62684. * Block used to implement the clear coat module of the PBR material
  62685. */
  62686. export class ClearCoatBlock extends NodeMaterialBlock {
  62687. private _scene;
  62688. /**
  62689. * Create a new ClearCoatBlock
  62690. * @param name defines the block name
  62691. */
  62692. constructor(name: string);
  62693. /**
  62694. * Initialize the block and prepare the context for build
  62695. * @param state defines the state that will be used for the build
  62696. */
  62697. initialize(state: NodeMaterialBuildState): void;
  62698. /**
  62699. * Gets the current class name
  62700. * @returns the class name
  62701. */
  62702. getClassName(): string;
  62703. /**
  62704. * Gets the intensity input component
  62705. */
  62706. get intensity(): NodeMaterialConnectionPoint;
  62707. /**
  62708. * Gets the roughness input component
  62709. */
  62710. get roughness(): NodeMaterialConnectionPoint;
  62711. /**
  62712. * Gets the ior input component
  62713. */
  62714. get ior(): NodeMaterialConnectionPoint;
  62715. /**
  62716. * Gets the texture input component
  62717. */
  62718. get texture(): NodeMaterialConnectionPoint;
  62719. /**
  62720. * Gets the bump texture input component
  62721. */
  62722. get bumpTexture(): NodeMaterialConnectionPoint;
  62723. /**
  62724. * Gets the uv input component
  62725. */
  62726. get uv(): NodeMaterialConnectionPoint;
  62727. /**
  62728. * Gets the tint color input component
  62729. */
  62730. get tintColor(): NodeMaterialConnectionPoint;
  62731. /**
  62732. * Gets the tint "at distance" input component
  62733. */
  62734. get tintAtDistance(): NodeMaterialConnectionPoint;
  62735. /**
  62736. * Gets the tint thickness input component
  62737. */
  62738. get tintThickness(): NodeMaterialConnectionPoint;
  62739. /**
  62740. * Gets the tint texture input component
  62741. */
  62742. get tintTexture(): NodeMaterialConnectionPoint;
  62743. /**
  62744. * Gets the world tangent input component
  62745. */
  62746. get worldTangent(): NodeMaterialConnectionPoint;
  62747. /**
  62748. * Gets the clear coat object output component
  62749. */
  62750. get clearcoat(): NodeMaterialConnectionPoint;
  62751. autoConfigure(material: NodeMaterial): void;
  62752. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62753. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  62754. private _generateTBNSpace;
  62755. /**
  62756. * Gets the main code of the block (fragment side)
  62757. * @param state current state of the node material building
  62758. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  62759. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  62760. * @param worldPosVarName name of the variable holding the world position
  62761. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  62762. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  62763. * @param worldNormalVarName name of the variable holding the world normal
  62764. * @returns the shader code
  62765. */
  62766. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  62767. protected _buildBlock(state: NodeMaterialBuildState): this;
  62768. }
  62769. }
  62770. declare module BABYLON {
  62771. /**
  62772. * Block used to implement the sub surface module of the PBR material
  62773. */
  62774. export class SubSurfaceBlock extends NodeMaterialBlock {
  62775. /**
  62776. * Create a new SubSurfaceBlock
  62777. * @param name defines the block name
  62778. */
  62779. constructor(name: string);
  62780. /**
  62781. * Stores the intensity of the different subsurface effects in the thickness texture.
  62782. * * the green channel is the translucency intensity.
  62783. * * the blue channel is the scattering intensity.
  62784. * * the alpha channel is the refraction intensity.
  62785. */
  62786. useMaskFromThicknessTexture: boolean;
  62787. /**
  62788. * Initialize the block and prepare the context for build
  62789. * @param state defines the state that will be used for the build
  62790. */
  62791. initialize(state: NodeMaterialBuildState): void;
  62792. /**
  62793. * Gets the current class name
  62794. * @returns the class name
  62795. */
  62796. getClassName(): string;
  62797. /**
  62798. * Gets the min thickness input component
  62799. */
  62800. get minThickness(): NodeMaterialConnectionPoint;
  62801. /**
  62802. * Gets the max thickness input component
  62803. */
  62804. get maxThickness(): NodeMaterialConnectionPoint;
  62805. /**
  62806. * Gets the thickness texture component
  62807. */
  62808. get thicknessTexture(): NodeMaterialConnectionPoint;
  62809. /**
  62810. * Gets the tint color input component
  62811. */
  62812. get tintColor(): NodeMaterialConnectionPoint;
  62813. /**
  62814. * Gets the translucency intensity input component
  62815. */
  62816. get translucencyIntensity(): NodeMaterialConnectionPoint;
  62817. /**
  62818. * Gets the translucency diffusion distance input component
  62819. */
  62820. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  62821. /**
  62822. * Gets the refraction object parameters
  62823. */
  62824. get refraction(): NodeMaterialConnectionPoint;
  62825. /**
  62826. * Gets the sub surface object output component
  62827. */
  62828. get subsurface(): NodeMaterialConnectionPoint;
  62829. autoConfigure(material: NodeMaterial): void;
  62830. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62831. /**
  62832. * Gets the main code of the block (fragment side)
  62833. * @param state current state of the node material building
  62834. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  62835. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  62836. * @param worldPosVarName name of the variable holding the world position
  62837. * @returns the shader code
  62838. */
  62839. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  62840. protected _buildBlock(state: NodeMaterialBuildState): this;
  62841. }
  62842. }
  62843. declare module BABYLON {
  62844. /**
  62845. * Block used to implement the PBR metallic/roughness model
  62846. */
  62847. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  62848. /**
  62849. * Gets or sets the light associated with this block
  62850. */
  62851. light: Nullable<Light>;
  62852. private _lightId;
  62853. private _scene;
  62854. private _environmentBRDFTexture;
  62855. private _environmentBrdfSamplerName;
  62856. private _vNormalWName;
  62857. private _invertNormalName;
  62858. /**
  62859. * Create a new ReflectionBlock
  62860. * @param name defines the block name
  62861. */
  62862. constructor(name: string);
  62863. /**
  62864. * Intensity of the direct lights e.g. the four lights available in your scene.
  62865. * This impacts both the direct diffuse and specular highlights.
  62866. */
  62867. directIntensity: number;
  62868. /**
  62869. * Intensity of the environment e.g. how much the environment will light the object
  62870. * either through harmonics for rough material or through the refelction for shiny ones.
  62871. */
  62872. environmentIntensity: number;
  62873. /**
  62874. * This is a special control allowing the reduction of the specular highlights coming from the
  62875. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  62876. */
  62877. specularIntensity: number;
  62878. /**
  62879. * Defines the falloff type used in this material.
  62880. * It by default is Physical.
  62881. */
  62882. lightFalloff: number;
  62883. /**
  62884. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  62885. */
  62886. useAlphaFromAlbedoTexture: boolean;
  62887. /**
  62888. * Specifies that alpha test should be used
  62889. */
  62890. useAlphaTest: boolean;
  62891. /**
  62892. * Defines the alpha limits in alpha test mode.
  62893. */
  62894. alphaTestCutoff: number;
  62895. /**
  62896. * Specifies that alpha blending should be used
  62897. */
  62898. useAlphaBlending: boolean;
  62899. /**
  62900. * Defines if the alpha value should be determined via the rgb values.
  62901. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  62902. */
  62903. opacityRGB: boolean;
  62904. /**
  62905. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  62906. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  62907. */
  62908. useRadianceOverAlpha: boolean;
  62909. /**
  62910. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  62911. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  62912. */
  62913. useSpecularOverAlpha: boolean;
  62914. /**
  62915. * Enables specular anti aliasing in the PBR shader.
  62916. * It will both interacts on the Geometry for analytical and IBL lighting.
  62917. * It also prefilter the roughness map based on the bump values.
  62918. */
  62919. enableSpecularAntiAliasing: boolean;
  62920. /**
  62921. * Defines if the material uses energy conservation.
  62922. */
  62923. useEnergyConservation: boolean;
  62924. /**
  62925. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  62926. * too much the area relying on ambient texture to define their ambient occlusion.
  62927. */
  62928. useRadianceOcclusion: boolean;
  62929. /**
  62930. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  62931. * makes the reflect vector face the model (under horizon).
  62932. */
  62933. useHorizonOcclusion: boolean;
  62934. /**
  62935. * If set to true, no lighting calculations will be applied.
  62936. */
  62937. unlit: boolean;
  62938. /**
  62939. * Force normal to face away from face.
  62940. */
  62941. forceNormalForward: boolean;
  62942. /**
  62943. * Defines the material debug mode.
  62944. * It helps seeing only some components of the material while troubleshooting.
  62945. */
  62946. debugMode: number;
  62947. /**
  62948. * Specify from where on screen the debug mode should start.
  62949. * The value goes from -1 (full screen) to 1 (not visible)
  62950. * It helps with side by side comparison against the final render
  62951. * This defaults to 0
  62952. */
  62953. debugLimit: number;
  62954. /**
  62955. * As the default viewing range might not be enough (if the ambient is really small for instance)
  62956. * You can use the factor to better multiply the final value.
  62957. */
  62958. debugFactor: number;
  62959. /**
  62960. * Initialize the block and prepare the context for build
  62961. * @param state defines the state that will be used for the build
  62962. */
  62963. initialize(state: NodeMaterialBuildState): void;
  62964. /**
  62965. * Gets the current class name
  62966. * @returns the class name
  62967. */
  62968. getClassName(): string;
  62969. /**
  62970. * Gets the world position input component
  62971. */
  62972. get worldPosition(): NodeMaterialConnectionPoint;
  62973. /**
  62974. * Gets the world normal input component
  62975. */
  62976. get worldNormal(): NodeMaterialConnectionPoint;
  62977. /**
  62978. * Gets the perturbed normal input component
  62979. */
  62980. get perturbedNormal(): NodeMaterialConnectionPoint;
  62981. /**
  62982. * Gets the camera position input component
  62983. */
  62984. get cameraPosition(): NodeMaterialConnectionPoint;
  62985. /**
  62986. * Gets the base color input component
  62987. */
  62988. get baseColor(): NodeMaterialConnectionPoint;
  62989. /**
  62990. * Gets the base texture input component
  62991. */
  62992. get baseTexture(): NodeMaterialConnectionPoint;
  62993. /**
  62994. * Gets the opacity texture input component
  62995. */
  62996. get opacityTexture(): NodeMaterialConnectionPoint;
  62997. /**
  62998. * Gets the ambient color input component
  62999. */
  63000. get ambientColor(): NodeMaterialConnectionPoint;
  63001. /**
  63002. * Gets the reflectivity object parameters
  63003. */
  63004. get reflectivity(): NodeMaterialConnectionPoint;
  63005. /**
  63006. * Gets the ambient occlusion object parameters
  63007. */
  63008. get ambientOcclusion(): NodeMaterialConnectionPoint;
  63009. /**
  63010. * Gets the reflection object parameters
  63011. */
  63012. get reflection(): NodeMaterialConnectionPoint;
  63013. /**
  63014. * Gets the sheen object parameters
  63015. */
  63016. get sheen(): NodeMaterialConnectionPoint;
  63017. /**
  63018. * Gets the clear coat object parameters
  63019. */
  63020. get clearcoat(): NodeMaterialConnectionPoint;
  63021. /**
  63022. * Gets the sub surface object parameters
  63023. */
  63024. get subsurface(): NodeMaterialConnectionPoint;
  63025. /**
  63026. * Gets the anisotropy object parameters
  63027. */
  63028. get anisotropy(): NodeMaterialConnectionPoint;
  63029. /**
  63030. * Gets the ambient output component
  63031. */
  63032. get ambient(): NodeMaterialConnectionPoint;
  63033. /**
  63034. * Gets the diffuse output component
  63035. */
  63036. get diffuse(): NodeMaterialConnectionPoint;
  63037. /**
  63038. * Gets the specular output component
  63039. */
  63040. get specular(): NodeMaterialConnectionPoint;
  63041. /**
  63042. * Gets the sheen output component
  63043. */
  63044. get sheenDir(): NodeMaterialConnectionPoint;
  63045. /**
  63046. * Gets the clear coat output component
  63047. */
  63048. get clearcoatDir(): NodeMaterialConnectionPoint;
  63049. /**
  63050. * Gets the indirect diffuse output component
  63051. */
  63052. get diffuseIndirect(): NodeMaterialConnectionPoint;
  63053. /**
  63054. * Gets the indirect specular output component
  63055. */
  63056. get specularIndirect(): NodeMaterialConnectionPoint;
  63057. /**
  63058. * Gets the indirect sheen output component
  63059. */
  63060. get sheenIndirect(): NodeMaterialConnectionPoint;
  63061. /**
  63062. * Gets the indirect clear coat output component
  63063. */
  63064. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  63065. /**
  63066. * Gets the refraction output component
  63067. */
  63068. get refraction(): NodeMaterialConnectionPoint;
  63069. /**
  63070. * Gets the global lighting output component
  63071. */
  63072. get lighting(): NodeMaterialConnectionPoint;
  63073. /**
  63074. * Gets the shadow output component
  63075. */
  63076. get shadow(): NodeMaterialConnectionPoint;
  63077. /**
  63078. * Gets the alpha output component
  63079. */
  63080. get alpha(): NodeMaterialConnectionPoint;
  63081. autoConfigure(material: NodeMaterial): void;
  63082. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63083. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  63084. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63085. private _injectVertexCode;
  63086. /**
  63087. * Gets the code corresponding to the albedo/opacity module
  63088. * @returns the shader code
  63089. */
  63090. getAlbedoOpacityCode(): string;
  63091. protected _buildBlock(state: NodeMaterialBuildState): this;
  63092. protected _dumpPropertiesCode(): string;
  63093. serialize(): any;
  63094. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63095. }
  63096. }
  63097. declare module BABYLON {
  63098. /**
  63099. * Block used to compute value of one parameter modulo another
  63100. */
  63101. export class ModBlock extends NodeMaterialBlock {
  63102. /**
  63103. * Creates a new ModBlock
  63104. * @param name defines the block name
  63105. */
  63106. constructor(name: string);
  63107. /**
  63108. * Gets the current class name
  63109. * @returns the class name
  63110. */
  63111. getClassName(): string;
  63112. /**
  63113. * Gets the left operand input component
  63114. */
  63115. get left(): NodeMaterialConnectionPoint;
  63116. /**
  63117. * Gets the right operand input component
  63118. */
  63119. get right(): NodeMaterialConnectionPoint;
  63120. /**
  63121. * Gets the output component
  63122. */
  63123. get output(): NodeMaterialConnectionPoint;
  63124. protected _buildBlock(state: NodeMaterialBuildState): this;
  63125. }
  63126. }
  63127. declare module BABYLON {
  63128. /**
  63129. * Helper class to push actions to a pool of workers.
  63130. */
  63131. export class WorkerPool implements IDisposable {
  63132. private _workerInfos;
  63133. private _pendingActions;
  63134. /**
  63135. * Constructor
  63136. * @param workers Array of workers to use for actions
  63137. */
  63138. constructor(workers: Array<Worker>);
  63139. /**
  63140. * Terminates all workers and clears any pending actions.
  63141. */
  63142. dispose(): void;
  63143. /**
  63144. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63145. * pended until a worker has completed its action.
  63146. * @param action The action to perform. Call onComplete when the action is complete.
  63147. */
  63148. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63149. private _execute;
  63150. }
  63151. }
  63152. declare module BABYLON {
  63153. /**
  63154. * Configuration for Draco compression
  63155. */
  63156. export interface IDracoCompressionConfiguration {
  63157. /**
  63158. * Configuration for the decoder.
  63159. */
  63160. decoder: {
  63161. /**
  63162. * The url to the WebAssembly module.
  63163. */
  63164. wasmUrl?: string;
  63165. /**
  63166. * The url to the WebAssembly binary.
  63167. */
  63168. wasmBinaryUrl?: string;
  63169. /**
  63170. * The url to the fallback JavaScript module.
  63171. */
  63172. fallbackUrl?: string;
  63173. };
  63174. }
  63175. /**
  63176. * Draco compression (https://google.github.io/draco/)
  63177. *
  63178. * This class wraps the Draco module.
  63179. *
  63180. * **Encoder**
  63181. *
  63182. * The encoder is not currently implemented.
  63183. *
  63184. * **Decoder**
  63185. *
  63186. * 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.
  63187. *
  63188. * To update the configuration, use the following code:
  63189. * ```javascript
  63190. * DracoCompression.Configuration = {
  63191. * decoder: {
  63192. * wasmUrl: "<url to the WebAssembly library>",
  63193. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63194. * fallbackUrl: "<url to the fallback JavaScript library>",
  63195. * }
  63196. * };
  63197. * ```
  63198. *
  63199. * 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.
  63200. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63201. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63202. *
  63203. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63204. * ```javascript
  63205. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63206. * ```
  63207. *
  63208. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63209. */
  63210. export class DracoCompression implements IDisposable {
  63211. private _workerPoolPromise?;
  63212. private _decoderModulePromise?;
  63213. /**
  63214. * The configuration. Defaults to the following urls:
  63215. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63216. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63217. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63218. */
  63219. static Configuration: IDracoCompressionConfiguration;
  63220. /**
  63221. * Returns true if the decoder configuration is available.
  63222. */
  63223. static get DecoderAvailable(): boolean;
  63224. /**
  63225. * Default number of workers to create when creating the draco compression object.
  63226. */
  63227. static DefaultNumWorkers: number;
  63228. private static GetDefaultNumWorkers;
  63229. private static _Default;
  63230. /**
  63231. * Default instance for the draco compression object.
  63232. */
  63233. static get Default(): DracoCompression;
  63234. /**
  63235. * Constructor
  63236. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63237. */
  63238. constructor(numWorkers?: number);
  63239. /**
  63240. * Stop all async operations and release resources.
  63241. */
  63242. dispose(): void;
  63243. /**
  63244. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  63245. * @returns a promise that resolves when ready
  63246. */
  63247. whenReadyAsync(): Promise<void>;
  63248. /**
  63249. * Decode Draco compressed mesh data to vertex data.
  63250. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  63251. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  63252. * @returns A promise that resolves with the decoded vertex data
  63253. */
  63254. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  63255. [kind: string]: number;
  63256. }): Promise<VertexData>;
  63257. }
  63258. }
  63259. declare module BABYLON {
  63260. /**
  63261. * Class for building Constructive Solid Geometry
  63262. */
  63263. export class CSG {
  63264. private polygons;
  63265. /**
  63266. * The world matrix
  63267. */
  63268. matrix: Matrix;
  63269. /**
  63270. * Stores the position
  63271. */
  63272. position: Vector3;
  63273. /**
  63274. * Stores the rotation
  63275. */
  63276. rotation: Vector3;
  63277. /**
  63278. * Stores the rotation quaternion
  63279. */
  63280. rotationQuaternion: Nullable<Quaternion>;
  63281. /**
  63282. * Stores the scaling vector
  63283. */
  63284. scaling: Vector3;
  63285. /**
  63286. * Convert the Mesh to CSG
  63287. * @param mesh The Mesh to convert to CSG
  63288. * @returns A new CSG from the Mesh
  63289. */
  63290. static FromMesh(mesh: Mesh): CSG;
  63291. /**
  63292. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  63293. * @param polygons Polygons used to construct a CSG solid
  63294. */
  63295. private static FromPolygons;
  63296. /**
  63297. * Clones, or makes a deep copy, of the CSG
  63298. * @returns A new CSG
  63299. */
  63300. clone(): CSG;
  63301. /**
  63302. * Unions this CSG with another CSG
  63303. * @param csg The CSG to union against this CSG
  63304. * @returns The unioned CSG
  63305. */
  63306. union(csg: CSG): CSG;
  63307. /**
  63308. * Unions this CSG with another CSG in place
  63309. * @param csg The CSG to union against this CSG
  63310. */
  63311. unionInPlace(csg: CSG): void;
  63312. /**
  63313. * Subtracts this CSG with another CSG
  63314. * @param csg The CSG to subtract against this CSG
  63315. * @returns A new CSG
  63316. */
  63317. subtract(csg: CSG): CSG;
  63318. /**
  63319. * Subtracts this CSG with another CSG in place
  63320. * @param csg The CSG to subtact against this CSG
  63321. */
  63322. subtractInPlace(csg: CSG): void;
  63323. /**
  63324. * Intersect this CSG with another CSG
  63325. * @param csg The CSG to intersect against this CSG
  63326. * @returns A new CSG
  63327. */
  63328. intersect(csg: CSG): CSG;
  63329. /**
  63330. * Intersects this CSG with another CSG in place
  63331. * @param csg The CSG to intersect against this CSG
  63332. */
  63333. intersectInPlace(csg: CSG): void;
  63334. /**
  63335. * Return a new CSG solid with solid and empty space switched. This solid is
  63336. * not modified.
  63337. * @returns A new CSG solid with solid and empty space switched
  63338. */
  63339. inverse(): CSG;
  63340. /**
  63341. * Inverses the CSG in place
  63342. */
  63343. inverseInPlace(): void;
  63344. /**
  63345. * This is used to keep meshes transformations so they can be restored
  63346. * when we build back a Babylon Mesh
  63347. * NB : All CSG operations are performed in world coordinates
  63348. * @param csg The CSG to copy the transform attributes from
  63349. * @returns This CSG
  63350. */
  63351. copyTransformAttributes(csg: CSG): CSG;
  63352. /**
  63353. * Build Raw mesh from CSG
  63354. * Coordinates here are in world space
  63355. * @param name The name of the mesh geometry
  63356. * @param scene The Scene
  63357. * @param keepSubMeshes Specifies if the submeshes should be kept
  63358. * @returns A new Mesh
  63359. */
  63360. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63361. /**
  63362. * Build Mesh from CSG taking material and transforms into account
  63363. * @param name The name of the Mesh
  63364. * @param material The material of the Mesh
  63365. * @param scene The Scene
  63366. * @param keepSubMeshes Specifies if submeshes should be kept
  63367. * @returns The new Mesh
  63368. */
  63369. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63370. }
  63371. }
  63372. declare module BABYLON {
  63373. /**
  63374. * Class used to create a trail following a mesh
  63375. */
  63376. export class TrailMesh extends Mesh {
  63377. private _generator;
  63378. private _autoStart;
  63379. private _running;
  63380. private _diameter;
  63381. private _length;
  63382. private _sectionPolygonPointsCount;
  63383. private _sectionVectors;
  63384. private _sectionNormalVectors;
  63385. private _beforeRenderObserver;
  63386. /**
  63387. * @constructor
  63388. * @param name The value used by scene.getMeshByName() to do a lookup.
  63389. * @param generator The mesh or transform node to generate a trail.
  63390. * @param scene The scene to add this mesh to.
  63391. * @param diameter Diameter of trailing mesh. Default is 1.
  63392. * @param length Length of trailing mesh. Default is 60.
  63393. * @param autoStart Automatically start trailing mesh. Default true.
  63394. */
  63395. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  63396. /**
  63397. * "TrailMesh"
  63398. * @returns "TrailMesh"
  63399. */
  63400. getClassName(): string;
  63401. private _createMesh;
  63402. /**
  63403. * Start trailing mesh.
  63404. */
  63405. start(): void;
  63406. /**
  63407. * Stop trailing mesh.
  63408. */
  63409. stop(): void;
  63410. /**
  63411. * Update trailing mesh geometry.
  63412. */
  63413. update(): void;
  63414. /**
  63415. * Returns a new TrailMesh object.
  63416. * @param name is a string, the name given to the new mesh
  63417. * @param newGenerator use new generator object for cloned trail mesh
  63418. * @returns a new mesh
  63419. */
  63420. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  63421. /**
  63422. * Serializes this trail mesh
  63423. * @param serializationObject object to write serialization to
  63424. */
  63425. serialize(serializationObject: any): void;
  63426. /**
  63427. * Parses a serialized trail mesh
  63428. * @param parsedMesh the serialized mesh
  63429. * @param scene the scene to create the trail mesh in
  63430. * @returns the created trail mesh
  63431. */
  63432. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  63433. }
  63434. }
  63435. declare module BABYLON {
  63436. /**
  63437. * Class containing static functions to help procedurally build meshes
  63438. */
  63439. export class TiledBoxBuilder {
  63440. /**
  63441. * Creates a box mesh
  63442. * 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)
  63443. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63444. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63445. * * 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
  63446. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63447. * @param name defines the name of the mesh
  63448. * @param options defines the options used to create the mesh
  63449. * @param scene defines the hosting scene
  63450. * @returns the box mesh
  63451. */
  63452. static CreateTiledBox(name: string, options: {
  63453. pattern?: number;
  63454. width?: number;
  63455. height?: number;
  63456. depth?: number;
  63457. tileSize?: number;
  63458. tileWidth?: number;
  63459. tileHeight?: number;
  63460. alignHorizontal?: number;
  63461. alignVertical?: number;
  63462. faceUV?: Vector4[];
  63463. faceColors?: Color4[];
  63464. sideOrientation?: number;
  63465. updatable?: boolean;
  63466. }, scene?: Nullable<Scene>): Mesh;
  63467. }
  63468. }
  63469. declare module BABYLON {
  63470. /**
  63471. * Class containing static functions to help procedurally build meshes
  63472. */
  63473. export class TorusKnotBuilder {
  63474. /**
  63475. * Creates a torus knot mesh
  63476. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63477. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63478. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63479. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63480. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63481. * * 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
  63482. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63483. * @param name defines the name of the mesh
  63484. * @param options defines the options used to create the mesh
  63485. * @param scene defines the hosting scene
  63486. * @returns the torus knot mesh
  63487. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63488. */
  63489. static CreateTorusKnot(name: string, options: {
  63490. radius?: number;
  63491. tube?: number;
  63492. radialSegments?: number;
  63493. tubularSegments?: number;
  63494. p?: number;
  63495. q?: number;
  63496. updatable?: boolean;
  63497. sideOrientation?: number;
  63498. frontUVs?: Vector4;
  63499. backUVs?: Vector4;
  63500. }, scene: any): Mesh;
  63501. }
  63502. }
  63503. declare module BABYLON {
  63504. /**
  63505. * Polygon
  63506. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  63507. */
  63508. export class Polygon {
  63509. /**
  63510. * Creates a rectangle
  63511. * @param xmin bottom X coord
  63512. * @param ymin bottom Y coord
  63513. * @param xmax top X coord
  63514. * @param ymax top Y coord
  63515. * @returns points that make the resulting rectation
  63516. */
  63517. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  63518. /**
  63519. * Creates a circle
  63520. * @param radius radius of circle
  63521. * @param cx scale in x
  63522. * @param cy scale in y
  63523. * @param numberOfSides number of sides that make up the circle
  63524. * @returns points that make the resulting circle
  63525. */
  63526. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  63527. /**
  63528. * Creates a polygon from input string
  63529. * @param input Input polygon data
  63530. * @returns the parsed points
  63531. */
  63532. static Parse(input: string): Vector2[];
  63533. /**
  63534. * Starts building a polygon from x and y coordinates
  63535. * @param x x coordinate
  63536. * @param y y coordinate
  63537. * @returns the started path2
  63538. */
  63539. static StartingAt(x: number, y: number): Path2;
  63540. }
  63541. /**
  63542. * Builds a polygon
  63543. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  63544. */
  63545. export class PolygonMeshBuilder {
  63546. private _points;
  63547. private _outlinepoints;
  63548. private _holes;
  63549. private _name;
  63550. private _scene;
  63551. private _epoints;
  63552. private _eholes;
  63553. private _addToepoint;
  63554. /**
  63555. * Babylon reference to the earcut plugin.
  63556. */
  63557. bjsEarcut: any;
  63558. /**
  63559. * Creates a PolygonMeshBuilder
  63560. * @param name name of the builder
  63561. * @param contours Path of the polygon
  63562. * @param scene scene to add to when creating the mesh
  63563. * @param earcutInjection can be used to inject your own earcut reference
  63564. */
  63565. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  63566. /**
  63567. * Adds a whole within the polygon
  63568. * @param hole Array of points defining the hole
  63569. * @returns this
  63570. */
  63571. addHole(hole: Vector2[]): PolygonMeshBuilder;
  63572. /**
  63573. * Creates the polygon
  63574. * @param updatable If the mesh should be updatable
  63575. * @param depth The depth of the mesh created
  63576. * @returns the created mesh
  63577. */
  63578. build(updatable?: boolean, depth?: number): Mesh;
  63579. /**
  63580. * Creates the polygon
  63581. * @param depth The depth of the mesh created
  63582. * @returns the created VertexData
  63583. */
  63584. buildVertexData(depth?: number): VertexData;
  63585. /**
  63586. * Adds a side to the polygon
  63587. * @param positions points that make the polygon
  63588. * @param normals normals of the polygon
  63589. * @param uvs uvs of the polygon
  63590. * @param indices indices of the polygon
  63591. * @param bounds bounds of the polygon
  63592. * @param points points of the polygon
  63593. * @param depth depth of the polygon
  63594. * @param flip flip of the polygon
  63595. */
  63596. private addSide;
  63597. }
  63598. }
  63599. declare module BABYLON {
  63600. /**
  63601. * Class containing static functions to help procedurally build meshes
  63602. */
  63603. export class PolygonBuilder {
  63604. /**
  63605. * Creates a polygon mesh
  63606. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  63607. * * 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
  63608. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63609. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63610. * * 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)
  63611. * * Remember you can only change the shape positions, not their number when updating a polygon
  63612. * @param name defines the name of the mesh
  63613. * @param options defines the options used to create the mesh
  63614. * @param scene defines the hosting scene
  63615. * @param earcutInjection can be used to inject your own earcut reference
  63616. * @returns the polygon mesh
  63617. */
  63618. static CreatePolygon(name: string, options: {
  63619. shape: Vector3[];
  63620. holes?: Vector3[][];
  63621. depth?: number;
  63622. faceUV?: Vector4[];
  63623. faceColors?: Color4[];
  63624. updatable?: boolean;
  63625. sideOrientation?: number;
  63626. frontUVs?: Vector4;
  63627. backUVs?: Vector4;
  63628. wrap?: boolean;
  63629. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63630. /**
  63631. * Creates an extruded polygon mesh, with depth in the Y direction.
  63632. * * 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)
  63633. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63634. * @param name defines the name of the mesh
  63635. * @param options defines the options used to create the mesh
  63636. * @param scene defines the hosting scene
  63637. * @param earcutInjection can be used to inject your own earcut reference
  63638. * @returns the polygon mesh
  63639. */
  63640. static ExtrudePolygon(name: string, options: {
  63641. shape: Vector3[];
  63642. holes?: Vector3[][];
  63643. depth?: number;
  63644. faceUV?: Vector4[];
  63645. faceColors?: Color4[];
  63646. updatable?: boolean;
  63647. sideOrientation?: number;
  63648. frontUVs?: Vector4;
  63649. backUVs?: Vector4;
  63650. wrap?: boolean;
  63651. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63652. }
  63653. }
  63654. declare module BABYLON {
  63655. /**
  63656. * Class containing static functions to help procedurally build meshes
  63657. */
  63658. export class LatheBuilder {
  63659. /**
  63660. * Creates lathe mesh.
  63661. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  63662. * * 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
  63663. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  63664. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  63665. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  63666. * * 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
  63667. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  63668. * * 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
  63669. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63670. * * 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
  63671. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63673. * @param name defines the name of the mesh
  63674. * @param options defines the options used to create the mesh
  63675. * @param scene defines the hosting scene
  63676. * @returns the lathe mesh
  63677. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  63678. */
  63679. static CreateLathe(name: string, options: {
  63680. shape: Vector3[];
  63681. radius?: number;
  63682. tessellation?: number;
  63683. clip?: number;
  63684. arc?: number;
  63685. closed?: boolean;
  63686. updatable?: boolean;
  63687. sideOrientation?: number;
  63688. frontUVs?: Vector4;
  63689. backUVs?: Vector4;
  63690. cap?: number;
  63691. invertUV?: boolean;
  63692. }, scene?: Nullable<Scene>): Mesh;
  63693. }
  63694. }
  63695. declare module BABYLON {
  63696. /**
  63697. * Class containing static functions to help procedurally build meshes
  63698. */
  63699. export class TiledPlaneBuilder {
  63700. /**
  63701. * Creates a tiled plane mesh
  63702. * * The parameter `pattern` will, depending on value, do nothing or
  63703. * * * flip (reflect about central vertical) alternate tiles across and up
  63704. * * * flip every tile on alternate rows
  63705. * * * rotate (180 degs) alternate tiles across and up
  63706. * * * rotate every tile on alternate rows
  63707. * * * flip and rotate alternate tiles across and up
  63708. * * * flip and rotate every tile on alternate rows
  63709. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  63710. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  63711. * * 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
  63712. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63713. * * 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)
  63714. * * 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)
  63715. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  63716. * @param name defines the name of the mesh
  63717. * @param options defines the options used to create the mesh
  63718. * @param scene defines the hosting scene
  63719. * @returns the box mesh
  63720. */
  63721. static CreateTiledPlane(name: string, options: {
  63722. pattern?: number;
  63723. tileSize?: number;
  63724. tileWidth?: number;
  63725. tileHeight?: number;
  63726. size?: number;
  63727. width?: number;
  63728. height?: number;
  63729. alignHorizontal?: number;
  63730. alignVertical?: number;
  63731. sideOrientation?: number;
  63732. frontUVs?: Vector4;
  63733. backUVs?: Vector4;
  63734. updatable?: boolean;
  63735. }, scene?: Nullable<Scene>): Mesh;
  63736. }
  63737. }
  63738. declare module BABYLON {
  63739. /**
  63740. * Class containing static functions to help procedurally build meshes
  63741. */
  63742. export class TubeBuilder {
  63743. /**
  63744. * Creates a tube mesh.
  63745. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63746. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  63747. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  63748. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  63749. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  63750. * * 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)
  63751. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  63752. * * 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
  63753. * * 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
  63754. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63755. * * 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
  63756. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63757. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63758. * @param name defines the name of the mesh
  63759. * @param options defines the options used to create the mesh
  63760. * @param scene defines the hosting scene
  63761. * @returns the tube mesh
  63762. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63763. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  63764. */
  63765. static CreateTube(name: string, options: {
  63766. path: Vector3[];
  63767. radius?: number;
  63768. tessellation?: number;
  63769. radiusFunction?: {
  63770. (i: number, distance: number): number;
  63771. };
  63772. cap?: number;
  63773. arc?: number;
  63774. updatable?: boolean;
  63775. sideOrientation?: number;
  63776. frontUVs?: Vector4;
  63777. backUVs?: Vector4;
  63778. instance?: Mesh;
  63779. invertUV?: boolean;
  63780. }, scene?: Nullable<Scene>): Mesh;
  63781. }
  63782. }
  63783. declare module BABYLON {
  63784. /**
  63785. * Class containing static functions to help procedurally build meshes
  63786. */
  63787. export class IcoSphereBuilder {
  63788. /**
  63789. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  63790. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  63791. * * 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`)
  63792. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  63793. * * 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
  63794. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63795. * * 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
  63796. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63797. * @param name defines the name of the mesh
  63798. * @param options defines the options used to create the mesh
  63799. * @param scene defines the hosting scene
  63800. * @returns the icosahedron mesh
  63801. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  63802. */
  63803. static CreateIcoSphere(name: string, options: {
  63804. radius?: number;
  63805. radiusX?: number;
  63806. radiusY?: number;
  63807. radiusZ?: number;
  63808. flat?: boolean;
  63809. subdivisions?: number;
  63810. sideOrientation?: number;
  63811. frontUVs?: Vector4;
  63812. backUVs?: Vector4;
  63813. updatable?: boolean;
  63814. }, scene?: Nullable<Scene>): Mesh;
  63815. }
  63816. }
  63817. declare module BABYLON {
  63818. /**
  63819. * Class containing static functions to help procedurally build meshes
  63820. */
  63821. export class DecalBuilder {
  63822. /**
  63823. * Creates a decal mesh.
  63824. * 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
  63825. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  63826. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  63827. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  63828. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  63829. * @param name defines the name of the mesh
  63830. * @param sourceMesh defines the mesh where the decal must be applied
  63831. * @param options defines the options used to create the mesh
  63832. * @param scene defines the hosting scene
  63833. * @returns the decal mesh
  63834. * @see https://doc.babylonjs.com/how_to/decals
  63835. */
  63836. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  63837. position?: Vector3;
  63838. normal?: Vector3;
  63839. size?: Vector3;
  63840. angle?: number;
  63841. }): Mesh;
  63842. }
  63843. }
  63844. declare module BABYLON {
  63845. /**
  63846. * Class containing static functions to help procedurally build meshes
  63847. */
  63848. export class MeshBuilder {
  63849. /**
  63850. * Creates a box mesh
  63851. * * The parameter `size` sets the size (float) of each box side (default 1)
  63852. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  63853. * * 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)
  63854. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63855. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63856. * * 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
  63857. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63858. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  63859. * @param name defines the name of the mesh
  63860. * @param options defines the options used to create the mesh
  63861. * @param scene defines the hosting scene
  63862. * @returns the box mesh
  63863. */
  63864. static CreateBox(name: string, options: {
  63865. size?: number;
  63866. width?: number;
  63867. height?: number;
  63868. depth?: number;
  63869. faceUV?: Vector4[];
  63870. faceColors?: Color4[];
  63871. sideOrientation?: number;
  63872. frontUVs?: Vector4;
  63873. backUVs?: Vector4;
  63874. wrap?: boolean;
  63875. topBaseAt?: number;
  63876. bottomBaseAt?: number;
  63877. updatable?: boolean;
  63878. }, scene?: Nullable<Scene>): Mesh;
  63879. /**
  63880. * Creates a tiled box mesh
  63881. * * faceTiles sets the pattern, tile size and number of tiles for a face
  63882. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63883. * @param name defines the name of the mesh
  63884. * @param options defines the options used to create the mesh
  63885. * @param scene defines the hosting scene
  63886. * @returns the tiled box mesh
  63887. */
  63888. static CreateTiledBox(name: string, options: {
  63889. pattern?: number;
  63890. size?: number;
  63891. width?: number;
  63892. height?: number;
  63893. depth: number;
  63894. tileSize?: number;
  63895. tileWidth?: number;
  63896. tileHeight?: number;
  63897. faceUV?: Vector4[];
  63898. faceColors?: Color4[];
  63899. alignHorizontal?: number;
  63900. alignVertical?: number;
  63901. sideOrientation?: number;
  63902. updatable?: boolean;
  63903. }, scene?: Nullable<Scene>): Mesh;
  63904. /**
  63905. * Creates a sphere mesh
  63906. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  63907. * * 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`)
  63908. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  63909. * * 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
  63910. * * 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)
  63911. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63912. * * 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
  63913. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63914. * @param name defines the name of the mesh
  63915. * @param options defines the options used to create the mesh
  63916. * @param scene defines the hosting scene
  63917. * @returns the sphere mesh
  63918. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  63919. */
  63920. static CreateSphere(name: string, options: {
  63921. segments?: number;
  63922. diameter?: number;
  63923. diameterX?: number;
  63924. diameterY?: number;
  63925. diameterZ?: number;
  63926. arc?: number;
  63927. slice?: number;
  63928. sideOrientation?: number;
  63929. frontUVs?: Vector4;
  63930. backUVs?: Vector4;
  63931. updatable?: boolean;
  63932. }, scene?: Nullable<Scene>): Mesh;
  63933. /**
  63934. * Creates a plane polygonal mesh. By default, this is a disc
  63935. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  63936. * * 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
  63937. * * 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
  63938. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63939. * * 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
  63940. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63941. * @param name defines the name of the mesh
  63942. * @param options defines the options used to create the mesh
  63943. * @param scene defines the hosting scene
  63944. * @returns the plane polygonal mesh
  63945. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  63946. */
  63947. static CreateDisc(name: string, options: {
  63948. radius?: number;
  63949. tessellation?: number;
  63950. arc?: number;
  63951. updatable?: boolean;
  63952. sideOrientation?: number;
  63953. frontUVs?: Vector4;
  63954. backUVs?: Vector4;
  63955. }, scene?: Nullable<Scene>): Mesh;
  63956. /**
  63957. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  63958. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  63959. * * 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`)
  63960. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  63961. * * 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
  63962. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63963. * * 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
  63964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63965. * @param name defines the name of the mesh
  63966. * @param options defines the options used to create the mesh
  63967. * @param scene defines the hosting scene
  63968. * @returns the icosahedron mesh
  63969. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  63970. */
  63971. static CreateIcoSphere(name: string, options: {
  63972. radius?: number;
  63973. radiusX?: number;
  63974. radiusY?: number;
  63975. radiusZ?: number;
  63976. flat?: boolean;
  63977. subdivisions?: number;
  63978. sideOrientation?: number;
  63979. frontUVs?: Vector4;
  63980. backUVs?: Vector4;
  63981. updatable?: boolean;
  63982. }, scene?: Nullable<Scene>): Mesh;
  63983. /**
  63984. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63985. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  63986. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  63987. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  63988. * * 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
  63989. * * 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
  63990. * * 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
  63991. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63992. * * 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
  63993. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63994. * * 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
  63995. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  63996. * * 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
  63997. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  63998. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63999. * @param name defines the name of the mesh
  64000. * @param options defines the options used to create the mesh
  64001. * @param scene defines the hosting scene
  64002. * @returns the ribbon mesh
  64003. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64004. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64005. */
  64006. static CreateRibbon(name: string, options: {
  64007. pathArray: Vector3[][];
  64008. closeArray?: boolean;
  64009. closePath?: boolean;
  64010. offset?: number;
  64011. updatable?: boolean;
  64012. sideOrientation?: number;
  64013. frontUVs?: Vector4;
  64014. backUVs?: Vector4;
  64015. instance?: Mesh;
  64016. invertUV?: boolean;
  64017. uvs?: Vector2[];
  64018. colors?: Color4[];
  64019. }, scene?: Nullable<Scene>): Mesh;
  64020. /**
  64021. * Creates a cylinder or a cone mesh
  64022. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64023. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64024. * * 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.
  64025. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64026. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64027. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64028. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64029. * * 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).
  64030. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64031. * * 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).
  64032. * * 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
  64033. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64034. * * 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
  64035. * * 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.
  64036. * * If `enclose` is false, a ring surface is one element.
  64037. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64038. * * 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
  64039. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64040. * * 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
  64041. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64042. * @param name defines the name of the mesh
  64043. * @param options defines the options used to create the mesh
  64044. * @param scene defines the hosting scene
  64045. * @returns the cylinder mesh
  64046. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64047. */
  64048. static CreateCylinder(name: string, options: {
  64049. height?: number;
  64050. diameterTop?: number;
  64051. diameterBottom?: number;
  64052. diameter?: number;
  64053. tessellation?: number;
  64054. subdivisions?: number;
  64055. arc?: number;
  64056. faceColors?: Color4[];
  64057. faceUV?: Vector4[];
  64058. updatable?: boolean;
  64059. hasRings?: boolean;
  64060. enclose?: boolean;
  64061. cap?: number;
  64062. sideOrientation?: number;
  64063. frontUVs?: Vector4;
  64064. backUVs?: Vector4;
  64065. }, scene?: Nullable<Scene>): Mesh;
  64066. /**
  64067. * Creates a torus mesh
  64068. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64069. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64070. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64071. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64072. * * 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
  64073. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64074. * @param name defines the name of the mesh
  64075. * @param options defines the options used to create the mesh
  64076. * @param scene defines the hosting scene
  64077. * @returns the torus mesh
  64078. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64079. */
  64080. static CreateTorus(name: string, options: {
  64081. diameter?: number;
  64082. thickness?: number;
  64083. tessellation?: number;
  64084. updatable?: boolean;
  64085. sideOrientation?: number;
  64086. frontUVs?: Vector4;
  64087. backUVs?: Vector4;
  64088. }, scene?: Nullable<Scene>): Mesh;
  64089. /**
  64090. * Creates a torus knot mesh
  64091. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64092. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64093. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64094. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64095. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64096. * * 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
  64097. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64098. * @param name defines the name of the mesh
  64099. * @param options defines the options used to create the mesh
  64100. * @param scene defines the hosting scene
  64101. * @returns the torus knot mesh
  64102. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64103. */
  64104. static CreateTorusKnot(name: string, options: {
  64105. radius?: number;
  64106. tube?: number;
  64107. radialSegments?: number;
  64108. tubularSegments?: number;
  64109. p?: number;
  64110. q?: number;
  64111. updatable?: boolean;
  64112. sideOrientation?: number;
  64113. frontUVs?: Vector4;
  64114. backUVs?: Vector4;
  64115. }, scene?: Nullable<Scene>): Mesh;
  64116. /**
  64117. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64118. * * 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
  64119. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64120. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64121. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64122. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64123. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64124. * * 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
  64125. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64126. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64127. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64128. * @param name defines the name of the new line system
  64129. * @param options defines the options used to create the line system
  64130. * @param scene defines the hosting scene
  64131. * @returns a new line system mesh
  64132. */
  64133. static CreateLineSystem(name: string, options: {
  64134. lines: Vector3[][];
  64135. updatable?: boolean;
  64136. instance?: Nullable<LinesMesh>;
  64137. colors?: Nullable<Color4[][]>;
  64138. useVertexAlpha?: boolean;
  64139. }, scene: Nullable<Scene>): LinesMesh;
  64140. /**
  64141. * Creates a line mesh
  64142. * 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
  64143. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64144. * * The parameter `points` is an array successive Vector3
  64145. * * 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
  64146. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64147. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64148. * * When updating an instance, remember that only point positions can change, not the number of points
  64149. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64150. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64151. * @param name defines the name of the new line system
  64152. * @param options defines the options used to create the line system
  64153. * @param scene defines the hosting scene
  64154. * @returns a new line mesh
  64155. */
  64156. static CreateLines(name: string, options: {
  64157. points: Vector3[];
  64158. updatable?: boolean;
  64159. instance?: Nullable<LinesMesh>;
  64160. colors?: Color4[];
  64161. useVertexAlpha?: boolean;
  64162. }, scene?: Nullable<Scene>): LinesMesh;
  64163. /**
  64164. * Creates a dashed line mesh
  64165. * * 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
  64166. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64167. * * The parameter `points` is an array successive Vector3
  64168. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64169. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64170. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64171. * * 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
  64172. * * When updating an instance, remember that only point positions can change, not the number of points
  64173. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64174. * @param name defines the name of the mesh
  64175. * @param options defines the options used to create the mesh
  64176. * @param scene defines the hosting scene
  64177. * @returns the dashed line mesh
  64178. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64179. */
  64180. static CreateDashedLines(name: string, options: {
  64181. points: Vector3[];
  64182. dashSize?: number;
  64183. gapSize?: number;
  64184. dashNb?: number;
  64185. updatable?: boolean;
  64186. instance?: LinesMesh;
  64187. }, scene?: Nullable<Scene>): LinesMesh;
  64188. /**
  64189. * 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.
  64190. * * 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.
  64191. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64192. * * 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.
  64193. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64194. * * 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
  64195. * * 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
  64196. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64197. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64198. * * 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
  64199. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  64200. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64201. * @param name defines the name of the mesh
  64202. * @param options defines the options used to create the mesh
  64203. * @param scene defines the hosting scene
  64204. * @returns the extruded shape mesh
  64205. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64206. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64207. */
  64208. static ExtrudeShape(name: string, options: {
  64209. shape: Vector3[];
  64210. path: Vector3[];
  64211. scale?: number;
  64212. rotation?: number;
  64213. cap?: number;
  64214. updatable?: boolean;
  64215. sideOrientation?: number;
  64216. frontUVs?: Vector4;
  64217. backUVs?: Vector4;
  64218. instance?: Mesh;
  64219. invertUV?: boolean;
  64220. }, scene?: Nullable<Scene>): Mesh;
  64221. /**
  64222. * Creates an custom extruded shape mesh.
  64223. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  64224. * * 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.
  64225. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64226. * * 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
  64227. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  64228. * * 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
  64229. * * It must returns a float value that will be the scale value applied to the shape on each path point
  64230. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  64231. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  64232. * * 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
  64233. * * 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
  64234. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  64235. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64236. * * 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
  64237. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64238. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64239. * @param name defines the name of the mesh
  64240. * @param options defines the options used to create the mesh
  64241. * @param scene defines the hosting scene
  64242. * @returns the custom extruded shape mesh
  64243. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  64244. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64245. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64246. */
  64247. static ExtrudeShapeCustom(name: string, options: {
  64248. shape: Vector3[];
  64249. path: Vector3[];
  64250. scaleFunction?: any;
  64251. rotationFunction?: any;
  64252. ribbonCloseArray?: boolean;
  64253. ribbonClosePath?: boolean;
  64254. cap?: number;
  64255. updatable?: boolean;
  64256. sideOrientation?: number;
  64257. frontUVs?: Vector4;
  64258. backUVs?: Vector4;
  64259. instance?: Mesh;
  64260. invertUV?: boolean;
  64261. }, scene?: Nullable<Scene>): Mesh;
  64262. /**
  64263. * Creates lathe mesh.
  64264. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64265. * * 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
  64266. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64267. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64268. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64269. * * 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
  64270. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64271. * * 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
  64272. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64273. * * 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
  64274. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64276. * @param name defines the name of the mesh
  64277. * @param options defines the options used to create the mesh
  64278. * @param scene defines the hosting scene
  64279. * @returns the lathe mesh
  64280. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64281. */
  64282. static CreateLathe(name: string, options: {
  64283. shape: Vector3[];
  64284. radius?: number;
  64285. tessellation?: number;
  64286. clip?: number;
  64287. arc?: number;
  64288. closed?: boolean;
  64289. updatable?: boolean;
  64290. sideOrientation?: number;
  64291. frontUVs?: Vector4;
  64292. backUVs?: Vector4;
  64293. cap?: number;
  64294. invertUV?: boolean;
  64295. }, scene?: Nullable<Scene>): Mesh;
  64296. /**
  64297. * Creates a tiled plane mesh
  64298. * * You can set a limited pattern arrangement with the tiles
  64299. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64300. * * 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
  64301. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64302. * @param name defines the name of the mesh
  64303. * @param options defines the options used to create the mesh
  64304. * @param scene defines the hosting scene
  64305. * @returns the plane mesh
  64306. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64307. */
  64308. static CreateTiledPlane(name: string, options: {
  64309. pattern?: number;
  64310. tileSize?: number;
  64311. tileWidth?: number;
  64312. tileHeight?: number;
  64313. size?: number;
  64314. width?: number;
  64315. height?: number;
  64316. alignHorizontal?: number;
  64317. alignVertical?: number;
  64318. sideOrientation?: number;
  64319. frontUVs?: Vector4;
  64320. backUVs?: Vector4;
  64321. updatable?: boolean;
  64322. }, scene?: Nullable<Scene>): Mesh;
  64323. /**
  64324. * Creates a plane mesh
  64325. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  64326. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  64327. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  64328. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64329. * * 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
  64330. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64331. * @param name defines the name of the mesh
  64332. * @param options defines the options used to create the mesh
  64333. * @param scene defines the hosting scene
  64334. * @returns the plane mesh
  64335. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64336. */
  64337. static CreatePlane(name: string, options: {
  64338. size?: number;
  64339. width?: number;
  64340. height?: number;
  64341. sideOrientation?: number;
  64342. frontUVs?: Vector4;
  64343. backUVs?: Vector4;
  64344. updatable?: boolean;
  64345. sourcePlane?: Plane;
  64346. }, scene?: Nullable<Scene>): Mesh;
  64347. /**
  64348. * Creates a ground mesh
  64349. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  64350. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  64351. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64352. * @param name defines the name of the mesh
  64353. * @param options defines the options used to create the mesh
  64354. * @param scene defines the hosting scene
  64355. * @returns the ground mesh
  64356. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  64357. */
  64358. static CreateGround(name: string, options: {
  64359. width?: number;
  64360. height?: number;
  64361. subdivisions?: number;
  64362. subdivisionsX?: number;
  64363. subdivisionsY?: number;
  64364. updatable?: boolean;
  64365. }, scene?: Nullable<Scene>): Mesh;
  64366. /**
  64367. * Creates a tiled ground mesh
  64368. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  64369. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  64370. * * 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
  64371. * * 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
  64372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64373. * @param name defines the name of the mesh
  64374. * @param options defines the options used to create the mesh
  64375. * @param scene defines the hosting scene
  64376. * @returns the tiled ground mesh
  64377. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  64378. */
  64379. static CreateTiledGround(name: string, options: {
  64380. xmin: number;
  64381. zmin: number;
  64382. xmax: number;
  64383. zmax: number;
  64384. subdivisions?: {
  64385. w: number;
  64386. h: number;
  64387. };
  64388. precision?: {
  64389. w: number;
  64390. h: number;
  64391. };
  64392. updatable?: boolean;
  64393. }, scene?: Nullable<Scene>): Mesh;
  64394. /**
  64395. * Creates a ground mesh from a height map
  64396. * * The parameter `url` sets the URL of the height map image resource.
  64397. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  64398. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  64399. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  64400. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  64401. * * 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.
  64402. * * 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).
  64403. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  64404. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64405. * @param name defines the name of the mesh
  64406. * @param url defines the url to the height map
  64407. * @param options defines the options used to create the mesh
  64408. * @param scene defines the hosting scene
  64409. * @returns the ground mesh
  64410. * @see https://doc.babylonjs.com/babylon101/height_map
  64411. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  64412. */
  64413. static CreateGroundFromHeightMap(name: string, url: string, options: {
  64414. width?: number;
  64415. height?: number;
  64416. subdivisions?: number;
  64417. minHeight?: number;
  64418. maxHeight?: number;
  64419. colorFilter?: Color3;
  64420. alphaFilter?: number;
  64421. updatable?: boolean;
  64422. onReady?: (mesh: GroundMesh) => void;
  64423. }, scene?: Nullable<Scene>): GroundMesh;
  64424. /**
  64425. * Creates a polygon mesh
  64426. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64427. * * 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
  64428. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64429. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64430. * * 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)
  64431. * * Remember you can only change the shape positions, not their number when updating a polygon
  64432. * @param name defines the name of the mesh
  64433. * @param options defines the options used to create the mesh
  64434. * @param scene defines the hosting scene
  64435. * @param earcutInjection can be used to inject your own earcut reference
  64436. * @returns the polygon mesh
  64437. */
  64438. static CreatePolygon(name: string, options: {
  64439. shape: Vector3[];
  64440. holes?: Vector3[][];
  64441. depth?: number;
  64442. faceUV?: Vector4[];
  64443. faceColors?: Color4[];
  64444. updatable?: boolean;
  64445. sideOrientation?: number;
  64446. frontUVs?: Vector4;
  64447. backUVs?: Vector4;
  64448. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64449. /**
  64450. * Creates an extruded polygon mesh, with depth in the Y direction.
  64451. * * 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)
  64452. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64453. * @param name defines the name of the mesh
  64454. * @param options defines the options used to create the mesh
  64455. * @param scene defines the hosting scene
  64456. * @param earcutInjection can be used to inject your own earcut reference
  64457. * @returns the polygon mesh
  64458. */
  64459. static ExtrudePolygon(name: string, options: {
  64460. shape: Vector3[];
  64461. holes?: Vector3[][];
  64462. depth?: number;
  64463. faceUV?: Vector4[];
  64464. faceColors?: Color4[];
  64465. updatable?: boolean;
  64466. sideOrientation?: number;
  64467. frontUVs?: Vector4;
  64468. backUVs?: Vector4;
  64469. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64470. /**
  64471. * Creates a tube mesh.
  64472. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64473. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64474. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64475. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64476. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64477. * * 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)
  64478. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64479. * * 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
  64480. * * 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
  64481. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64482. * * 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
  64483. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64484. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64485. * @param name defines the name of the mesh
  64486. * @param options defines the options used to create the mesh
  64487. * @param scene defines the hosting scene
  64488. * @returns the tube mesh
  64489. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64490. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64491. */
  64492. static CreateTube(name: string, options: {
  64493. path: Vector3[];
  64494. radius?: number;
  64495. tessellation?: number;
  64496. radiusFunction?: {
  64497. (i: number, distance: number): number;
  64498. };
  64499. cap?: number;
  64500. arc?: number;
  64501. updatable?: boolean;
  64502. sideOrientation?: number;
  64503. frontUVs?: Vector4;
  64504. backUVs?: Vector4;
  64505. instance?: Mesh;
  64506. invertUV?: boolean;
  64507. }, scene?: Nullable<Scene>): Mesh;
  64508. /**
  64509. * Creates a polyhedron mesh
  64510. * * 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
  64511. * * The parameter `size` (positive float, default 1) sets the polygon size
  64512. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  64513. * * 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`
  64514. * * 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
  64515. * * 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)`)
  64516. * * 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
  64517. * * 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
  64518. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64519. * * 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
  64520. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64521. * @param name defines the name of the mesh
  64522. * @param options defines the options used to create the mesh
  64523. * @param scene defines the hosting scene
  64524. * @returns the polyhedron mesh
  64525. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  64526. */
  64527. static CreatePolyhedron(name: string, options: {
  64528. type?: number;
  64529. size?: number;
  64530. sizeX?: number;
  64531. sizeY?: number;
  64532. sizeZ?: number;
  64533. custom?: any;
  64534. faceUV?: Vector4[];
  64535. faceColors?: Color4[];
  64536. flat?: boolean;
  64537. updatable?: boolean;
  64538. sideOrientation?: number;
  64539. frontUVs?: Vector4;
  64540. backUVs?: Vector4;
  64541. }, scene?: Nullable<Scene>): Mesh;
  64542. /**
  64543. * Creates a decal mesh.
  64544. * 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
  64545. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64546. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64547. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64548. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64549. * @param name defines the name of the mesh
  64550. * @param sourceMesh defines the mesh where the decal must be applied
  64551. * @param options defines the options used to create the mesh
  64552. * @param scene defines the hosting scene
  64553. * @returns the decal mesh
  64554. * @see https://doc.babylonjs.com/how_to/decals
  64555. */
  64556. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64557. position?: Vector3;
  64558. normal?: Vector3;
  64559. size?: Vector3;
  64560. angle?: number;
  64561. }): Mesh;
  64562. }
  64563. }
  64564. declare module BABYLON {
  64565. /**
  64566. * A simplifier interface for future simplification implementations
  64567. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64568. */
  64569. export interface ISimplifier {
  64570. /**
  64571. * Simplification of a given mesh according to the given settings.
  64572. * Since this requires computation, it is assumed that the function runs async.
  64573. * @param settings The settings of the simplification, including quality and distance
  64574. * @param successCallback A callback that will be called after the mesh was simplified.
  64575. * @param errorCallback in case of an error, this callback will be called. optional.
  64576. */
  64577. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  64578. }
  64579. /**
  64580. * Expected simplification settings.
  64581. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  64582. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64583. */
  64584. export interface ISimplificationSettings {
  64585. /**
  64586. * Gets or sets the expected quality
  64587. */
  64588. quality: number;
  64589. /**
  64590. * Gets or sets the distance when this optimized version should be used
  64591. */
  64592. distance: number;
  64593. /**
  64594. * Gets an already optimized mesh
  64595. */
  64596. optimizeMesh?: boolean;
  64597. }
  64598. /**
  64599. * Class used to specify simplification options
  64600. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64601. */
  64602. export class SimplificationSettings implements ISimplificationSettings {
  64603. /** expected quality */
  64604. quality: number;
  64605. /** distance when this optimized version should be used */
  64606. distance: number;
  64607. /** already optimized mesh */
  64608. optimizeMesh?: boolean | undefined;
  64609. /**
  64610. * Creates a SimplificationSettings
  64611. * @param quality expected quality
  64612. * @param distance distance when this optimized version should be used
  64613. * @param optimizeMesh already optimized mesh
  64614. */
  64615. constructor(
  64616. /** expected quality */
  64617. quality: number,
  64618. /** distance when this optimized version should be used */
  64619. distance: number,
  64620. /** already optimized mesh */
  64621. optimizeMesh?: boolean | undefined);
  64622. }
  64623. /**
  64624. * Interface used to define a simplification task
  64625. */
  64626. export interface ISimplificationTask {
  64627. /**
  64628. * Array of settings
  64629. */
  64630. settings: Array<ISimplificationSettings>;
  64631. /**
  64632. * Simplification type
  64633. */
  64634. simplificationType: SimplificationType;
  64635. /**
  64636. * Mesh to simplify
  64637. */
  64638. mesh: Mesh;
  64639. /**
  64640. * Callback called on success
  64641. */
  64642. successCallback?: () => void;
  64643. /**
  64644. * Defines if parallel processing can be used
  64645. */
  64646. parallelProcessing: boolean;
  64647. }
  64648. /**
  64649. * Queue used to order the simplification tasks
  64650. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64651. */
  64652. export class SimplificationQueue {
  64653. private _simplificationArray;
  64654. /**
  64655. * Gets a boolean indicating that the process is still running
  64656. */
  64657. running: boolean;
  64658. /**
  64659. * Creates a new queue
  64660. */
  64661. constructor();
  64662. /**
  64663. * Adds a new simplification task
  64664. * @param task defines a task to add
  64665. */
  64666. addTask(task: ISimplificationTask): void;
  64667. /**
  64668. * Execute next task
  64669. */
  64670. executeNext(): void;
  64671. /**
  64672. * Execute a simplification task
  64673. * @param task defines the task to run
  64674. */
  64675. runSimplification(task: ISimplificationTask): void;
  64676. private getSimplifier;
  64677. }
  64678. /**
  64679. * The implemented types of simplification
  64680. * At the moment only Quadratic Error Decimation is implemented
  64681. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64682. */
  64683. export enum SimplificationType {
  64684. /** Quadratic error decimation */
  64685. QUADRATIC = 0
  64686. }
  64687. /**
  64688. * An implementation of the Quadratic Error simplification algorithm.
  64689. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  64690. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  64691. * @author RaananW
  64692. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64693. */
  64694. export class QuadraticErrorSimplification implements ISimplifier {
  64695. private _mesh;
  64696. private triangles;
  64697. private vertices;
  64698. private references;
  64699. private _reconstructedMesh;
  64700. /** Gets or sets the number pf sync interations */
  64701. syncIterations: number;
  64702. /** Gets or sets the aggressiveness of the simplifier */
  64703. aggressiveness: number;
  64704. /** Gets or sets the number of allowed iterations for decimation */
  64705. decimationIterations: number;
  64706. /** Gets or sets the espilon to use for bounding box computation */
  64707. boundingBoxEpsilon: number;
  64708. /**
  64709. * Creates a new QuadraticErrorSimplification
  64710. * @param _mesh defines the target mesh
  64711. */
  64712. constructor(_mesh: Mesh);
  64713. /**
  64714. * Simplification of a given mesh according to the given settings.
  64715. * Since this requires computation, it is assumed that the function runs async.
  64716. * @param settings The settings of the simplification, including quality and distance
  64717. * @param successCallback A callback that will be called after the mesh was simplified.
  64718. */
  64719. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  64720. private runDecimation;
  64721. private initWithMesh;
  64722. private init;
  64723. private reconstructMesh;
  64724. private initDecimatedMesh;
  64725. private isFlipped;
  64726. private updateTriangles;
  64727. private identifyBorder;
  64728. private updateMesh;
  64729. private vertexError;
  64730. private calculateError;
  64731. }
  64732. }
  64733. declare module BABYLON {
  64734. interface Scene {
  64735. /** @hidden (Backing field) */
  64736. _simplificationQueue: SimplificationQueue;
  64737. /**
  64738. * Gets or sets the simplification queue attached to the scene
  64739. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64740. */
  64741. simplificationQueue: SimplificationQueue;
  64742. }
  64743. interface Mesh {
  64744. /**
  64745. * Simplify the mesh according to the given array of settings.
  64746. * Function will return immediately and will simplify async
  64747. * @param settings a collection of simplification settings
  64748. * @param parallelProcessing should all levels calculate parallel or one after the other
  64749. * @param simplificationType the type of simplification to run
  64750. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  64751. * @returns the current mesh
  64752. */
  64753. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  64754. }
  64755. /**
  64756. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  64757. * created in a scene
  64758. */
  64759. export class SimplicationQueueSceneComponent implements ISceneComponent {
  64760. /**
  64761. * The component name helpfull to identify the component in the list of scene components.
  64762. */
  64763. readonly name: string;
  64764. /**
  64765. * The scene the component belongs to.
  64766. */
  64767. scene: Scene;
  64768. /**
  64769. * Creates a new instance of the component for the given scene
  64770. * @param scene Defines the scene to register the component in
  64771. */
  64772. constructor(scene: Scene);
  64773. /**
  64774. * Registers the component in a given scene
  64775. */
  64776. register(): void;
  64777. /**
  64778. * Rebuilds the elements related to this component in case of
  64779. * context lost for instance.
  64780. */
  64781. rebuild(): void;
  64782. /**
  64783. * Disposes the component and the associated ressources
  64784. */
  64785. dispose(): void;
  64786. private _beforeCameraUpdate;
  64787. }
  64788. }
  64789. declare module BABYLON {
  64790. /**
  64791. * Navigation plugin interface to add navigation constrained by a navigation mesh
  64792. */
  64793. export interface INavigationEnginePlugin {
  64794. /**
  64795. * plugin name
  64796. */
  64797. name: string;
  64798. /**
  64799. * Creates a navigation mesh
  64800. * @param meshes array of all the geometry used to compute the navigatio mesh
  64801. * @param parameters bunch of parameters used to filter geometry
  64802. */
  64803. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  64804. /**
  64805. * Create a navigation mesh debug mesh
  64806. * @param scene is where the mesh will be added
  64807. * @returns debug display mesh
  64808. */
  64809. createDebugNavMesh(scene: Scene): Mesh;
  64810. /**
  64811. * Get a navigation mesh constrained position, closest to the parameter position
  64812. * @param position world position
  64813. * @returns the closest point to position constrained by the navigation mesh
  64814. */
  64815. getClosestPoint(position: Vector3): Vector3;
  64816. /**
  64817. * Get a navigation mesh constrained position, closest to the parameter position
  64818. * @param position world position
  64819. * @param result output the closest point to position constrained by the navigation mesh
  64820. */
  64821. getClosestPointToRef(position: Vector3, result: Vector3): void;
  64822. /**
  64823. * Get a navigation mesh constrained position, within a particular radius
  64824. * @param position world position
  64825. * @param maxRadius the maximum distance to the constrained world position
  64826. * @returns the closest point to position constrained by the navigation mesh
  64827. */
  64828. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  64829. /**
  64830. * Get a navigation mesh constrained position, within a particular radius
  64831. * @param position world position
  64832. * @param maxRadius the maximum distance to the constrained world position
  64833. * @param result output the closest point to position constrained by the navigation mesh
  64834. */
  64835. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  64836. /**
  64837. * Compute the final position from a segment made of destination-position
  64838. * @param position world position
  64839. * @param destination world position
  64840. * @returns the resulting point along the navmesh
  64841. */
  64842. moveAlong(position: Vector3, destination: Vector3): Vector3;
  64843. /**
  64844. * Compute the final position from a segment made of destination-position
  64845. * @param position world position
  64846. * @param destination world position
  64847. * @param result output the resulting point along the navmesh
  64848. */
  64849. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  64850. /**
  64851. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  64852. * @param start world position
  64853. * @param end world position
  64854. * @returns array containing world position composing the path
  64855. */
  64856. computePath(start: Vector3, end: Vector3): Vector3[];
  64857. /**
  64858. * If this plugin is supported
  64859. * @returns true if plugin is supported
  64860. */
  64861. isSupported(): boolean;
  64862. /**
  64863. * Create a new Crowd so you can add agents
  64864. * @param maxAgents the maximum agent count in the crowd
  64865. * @param maxAgentRadius the maximum radius an agent can have
  64866. * @param scene to attach the crowd to
  64867. * @returns the crowd you can add agents to
  64868. */
  64869. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  64870. /**
  64871. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  64872. * The queries will try to find a solution within those bounds
  64873. * default is (1,1,1)
  64874. * @param extent x,y,z value that define the extent around the queries point of reference
  64875. */
  64876. setDefaultQueryExtent(extent: Vector3): void;
  64877. /**
  64878. * Get the Bounding box extent specified by setDefaultQueryExtent
  64879. * @returns the box extent values
  64880. */
  64881. getDefaultQueryExtent(): Vector3;
  64882. /**
  64883. * build the navmesh from a previously saved state using getNavmeshData
  64884. * @param data the Uint8Array returned by getNavmeshData
  64885. */
  64886. buildFromNavmeshData(data: Uint8Array): void;
  64887. /**
  64888. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  64889. * @returns data the Uint8Array that can be saved and reused
  64890. */
  64891. getNavmeshData(): Uint8Array;
  64892. /**
  64893. * Get the Bounding box extent result specified by setDefaultQueryExtent
  64894. * @param result output the box extent values
  64895. */
  64896. getDefaultQueryExtentToRef(result: Vector3): void;
  64897. /**
  64898. * Release all resources
  64899. */
  64900. dispose(): void;
  64901. }
  64902. /**
  64903. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  64904. */
  64905. export interface ICrowd {
  64906. /**
  64907. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  64908. * You can attach anything to that node. The node position is updated in the scene update tick.
  64909. * @param pos world position that will be constrained by the navigation mesh
  64910. * @param parameters agent parameters
  64911. * @param transform hooked to the agent that will be update by the scene
  64912. * @returns agent index
  64913. */
  64914. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  64915. /**
  64916. * Returns the agent position in world space
  64917. * @param index agent index returned by addAgent
  64918. * @returns world space position
  64919. */
  64920. getAgentPosition(index: number): Vector3;
  64921. /**
  64922. * Gets the agent position result in world space
  64923. * @param index agent index returned by addAgent
  64924. * @param result output world space position
  64925. */
  64926. getAgentPositionToRef(index: number, result: Vector3): void;
  64927. /**
  64928. * Gets the agent velocity in world space
  64929. * @param index agent index returned by addAgent
  64930. * @returns world space velocity
  64931. */
  64932. getAgentVelocity(index: number): Vector3;
  64933. /**
  64934. * Gets the agent velocity result in world space
  64935. * @param index agent index returned by addAgent
  64936. * @param result output world space velocity
  64937. */
  64938. getAgentVelocityToRef(index: number, result: Vector3): void;
  64939. /**
  64940. * remove a particular agent previously created
  64941. * @param index agent index returned by addAgent
  64942. */
  64943. removeAgent(index: number): void;
  64944. /**
  64945. * get the list of all agents attached to this crowd
  64946. * @returns list of agent indices
  64947. */
  64948. getAgents(): number[];
  64949. /**
  64950. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  64951. * @param deltaTime in seconds
  64952. */
  64953. update(deltaTime: number): void;
  64954. /**
  64955. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  64956. * @param index agent index returned by addAgent
  64957. * @param destination targeted world position
  64958. */
  64959. agentGoto(index: number, destination: Vector3): void;
  64960. /**
  64961. * Teleport the agent to a new position
  64962. * @param index agent index returned by addAgent
  64963. * @param destination targeted world position
  64964. */
  64965. agentTeleport(index: number, destination: Vector3): void;
  64966. /**
  64967. * Update agent parameters
  64968. * @param index agent index returned by addAgent
  64969. * @param parameters agent parameters
  64970. */
  64971. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  64972. /**
  64973. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  64974. * The queries will try to find a solution within those bounds
  64975. * default is (1,1,1)
  64976. * @param extent x,y,z value that define the extent around the queries point of reference
  64977. */
  64978. setDefaultQueryExtent(extent: Vector3): void;
  64979. /**
  64980. * Get the Bounding box extent specified by setDefaultQueryExtent
  64981. * @returns the box extent values
  64982. */
  64983. getDefaultQueryExtent(): Vector3;
  64984. /**
  64985. * Get the Bounding box extent result specified by setDefaultQueryExtent
  64986. * @param result output the box extent values
  64987. */
  64988. getDefaultQueryExtentToRef(result: Vector3): void;
  64989. /**
  64990. * Release all resources
  64991. */
  64992. dispose(): void;
  64993. }
  64994. /**
  64995. * Configures an agent
  64996. */
  64997. export interface IAgentParameters {
  64998. /**
  64999. * Agent radius. [Limit: >= 0]
  65000. */
  65001. radius: number;
  65002. /**
  65003. * Agent height. [Limit: > 0]
  65004. */
  65005. height: number;
  65006. /**
  65007. * Maximum allowed acceleration. [Limit: >= 0]
  65008. */
  65009. maxAcceleration: number;
  65010. /**
  65011. * Maximum allowed speed. [Limit: >= 0]
  65012. */
  65013. maxSpeed: number;
  65014. /**
  65015. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65016. */
  65017. collisionQueryRange: number;
  65018. /**
  65019. * The path visibility optimization range. [Limit: > 0]
  65020. */
  65021. pathOptimizationRange: number;
  65022. /**
  65023. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65024. */
  65025. separationWeight: number;
  65026. }
  65027. /**
  65028. * Configures the navigation mesh creation
  65029. */
  65030. export interface INavMeshParameters {
  65031. /**
  65032. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65033. */
  65034. cs: number;
  65035. /**
  65036. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65037. */
  65038. ch: number;
  65039. /**
  65040. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65041. */
  65042. walkableSlopeAngle: number;
  65043. /**
  65044. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65045. * be considered walkable. [Limit: >= 3] [Units: vx]
  65046. */
  65047. walkableHeight: number;
  65048. /**
  65049. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65050. */
  65051. walkableClimb: number;
  65052. /**
  65053. * The distance to erode/shrink the walkable area of the heightfield away from
  65054. * obstructions. [Limit: >=0] [Units: vx]
  65055. */
  65056. walkableRadius: number;
  65057. /**
  65058. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65059. */
  65060. maxEdgeLen: number;
  65061. /**
  65062. * The maximum distance a simplfied contour's border edges should deviate
  65063. * the original raw contour. [Limit: >=0] [Units: vx]
  65064. */
  65065. maxSimplificationError: number;
  65066. /**
  65067. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65068. */
  65069. minRegionArea: number;
  65070. /**
  65071. * Any regions with a span count smaller than this value will, if possible,
  65072. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65073. */
  65074. mergeRegionArea: number;
  65075. /**
  65076. * The maximum number of vertices allowed for polygons generated during the
  65077. * contour to polygon conversion process. [Limit: >= 3]
  65078. */
  65079. maxVertsPerPoly: number;
  65080. /**
  65081. * Sets the sampling distance to use when generating the detail mesh.
  65082. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65083. */
  65084. detailSampleDist: number;
  65085. /**
  65086. * The maximum distance the detail mesh surface should deviate from heightfield
  65087. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65088. */
  65089. detailSampleMaxError: number;
  65090. }
  65091. }
  65092. declare module BABYLON {
  65093. /**
  65094. * RecastJS navigation plugin
  65095. */
  65096. export class RecastJSPlugin implements INavigationEnginePlugin {
  65097. /**
  65098. * Reference to the Recast library
  65099. */
  65100. bjsRECAST: any;
  65101. /**
  65102. * plugin name
  65103. */
  65104. name: string;
  65105. /**
  65106. * the first navmesh created. We might extend this to support multiple navmeshes
  65107. */
  65108. navMesh: any;
  65109. /**
  65110. * Initializes the recastJS plugin
  65111. * @param recastInjection can be used to inject your own recast reference
  65112. */
  65113. constructor(recastInjection?: any);
  65114. /**
  65115. * Creates a navigation mesh
  65116. * @param meshes array of all the geometry used to compute the navigatio mesh
  65117. * @param parameters bunch of parameters used to filter geometry
  65118. */
  65119. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65120. /**
  65121. * Create a navigation mesh debug mesh
  65122. * @param scene is where the mesh will be added
  65123. * @returns debug display mesh
  65124. */
  65125. createDebugNavMesh(scene: Scene): Mesh;
  65126. /**
  65127. * Get a navigation mesh constrained position, closest to the parameter position
  65128. * @param position world position
  65129. * @returns the closest point to position constrained by the navigation mesh
  65130. */
  65131. getClosestPoint(position: Vector3): Vector3;
  65132. /**
  65133. * Get a navigation mesh constrained position, closest to the parameter position
  65134. * @param position world position
  65135. * @param result output the closest point to position constrained by the navigation mesh
  65136. */
  65137. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65138. /**
  65139. * Get a navigation mesh constrained position, within a particular radius
  65140. * @param position world position
  65141. * @param maxRadius the maximum distance to the constrained world position
  65142. * @returns the closest point to position constrained by the navigation mesh
  65143. */
  65144. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65145. /**
  65146. * Get a navigation mesh constrained position, within a particular radius
  65147. * @param position world position
  65148. * @param maxRadius the maximum distance to the constrained world position
  65149. * @param result output the closest point to position constrained by the navigation mesh
  65150. */
  65151. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65152. /**
  65153. * Compute the final position from a segment made of destination-position
  65154. * @param position world position
  65155. * @param destination world position
  65156. * @returns the resulting point along the navmesh
  65157. */
  65158. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65159. /**
  65160. * Compute the final position from a segment made of destination-position
  65161. * @param position world position
  65162. * @param destination world position
  65163. * @param result output the resulting point along the navmesh
  65164. */
  65165. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65166. /**
  65167. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65168. * @param start world position
  65169. * @param end world position
  65170. * @returns array containing world position composing the path
  65171. */
  65172. computePath(start: Vector3, end: Vector3): Vector3[];
  65173. /**
  65174. * Create a new Crowd so you can add agents
  65175. * @param maxAgents the maximum agent count in the crowd
  65176. * @param maxAgentRadius the maximum radius an agent can have
  65177. * @param scene to attach the crowd to
  65178. * @returns the crowd you can add agents to
  65179. */
  65180. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65181. /**
  65182. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65183. * The queries will try to find a solution within those bounds
  65184. * default is (1,1,1)
  65185. * @param extent x,y,z value that define the extent around the queries point of reference
  65186. */
  65187. setDefaultQueryExtent(extent: Vector3): void;
  65188. /**
  65189. * Get the Bounding box extent specified by setDefaultQueryExtent
  65190. * @returns the box extent values
  65191. */
  65192. getDefaultQueryExtent(): Vector3;
  65193. /**
  65194. * build the navmesh from a previously saved state using getNavmeshData
  65195. * @param data the Uint8Array returned by getNavmeshData
  65196. */
  65197. buildFromNavmeshData(data: Uint8Array): void;
  65198. /**
  65199. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65200. * @returns data the Uint8Array that can be saved and reused
  65201. */
  65202. getNavmeshData(): Uint8Array;
  65203. /**
  65204. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65205. * @param result output the box extent values
  65206. */
  65207. getDefaultQueryExtentToRef(result: Vector3): void;
  65208. /**
  65209. * Disposes
  65210. */
  65211. dispose(): void;
  65212. /**
  65213. * If this plugin is supported
  65214. * @returns true if plugin is supported
  65215. */
  65216. isSupported(): boolean;
  65217. }
  65218. /**
  65219. * Recast detour crowd implementation
  65220. */
  65221. export class RecastJSCrowd implements ICrowd {
  65222. /**
  65223. * Recast/detour plugin
  65224. */
  65225. bjsRECASTPlugin: RecastJSPlugin;
  65226. /**
  65227. * Link to the detour crowd
  65228. */
  65229. recastCrowd: any;
  65230. /**
  65231. * One transform per agent
  65232. */
  65233. transforms: TransformNode[];
  65234. /**
  65235. * All agents created
  65236. */
  65237. agents: number[];
  65238. /**
  65239. * Link to the scene is kept to unregister the crowd from the scene
  65240. */
  65241. private _scene;
  65242. /**
  65243. * Observer for crowd updates
  65244. */
  65245. private _onBeforeAnimationsObserver;
  65246. /**
  65247. * Constructor
  65248. * @param plugin recastJS plugin
  65249. * @param maxAgents the maximum agent count in the crowd
  65250. * @param maxAgentRadius the maximum radius an agent can have
  65251. * @param scene to attach the crowd to
  65252. * @returns the crowd you can add agents to
  65253. */
  65254. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  65255. /**
  65256. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65257. * You can attach anything to that node. The node position is updated in the scene update tick.
  65258. * @param pos world position that will be constrained by the navigation mesh
  65259. * @param parameters agent parameters
  65260. * @param transform hooked to the agent that will be update by the scene
  65261. * @returns agent index
  65262. */
  65263. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65264. /**
  65265. * Returns the agent position in world space
  65266. * @param index agent index returned by addAgent
  65267. * @returns world space position
  65268. */
  65269. getAgentPosition(index: number): Vector3;
  65270. /**
  65271. * Returns the agent position result in world space
  65272. * @param index agent index returned by addAgent
  65273. * @param result output world space position
  65274. */
  65275. getAgentPositionToRef(index: number, result: Vector3): void;
  65276. /**
  65277. * Returns the agent velocity in world space
  65278. * @param index agent index returned by addAgent
  65279. * @returns world space velocity
  65280. */
  65281. getAgentVelocity(index: number): Vector3;
  65282. /**
  65283. * Returns the agent velocity result in world space
  65284. * @param index agent index returned by addAgent
  65285. * @param result output world space velocity
  65286. */
  65287. getAgentVelocityToRef(index: number, result: Vector3): void;
  65288. /**
  65289. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65290. * @param index agent index returned by addAgent
  65291. * @param destination targeted world position
  65292. */
  65293. agentGoto(index: number, destination: Vector3): void;
  65294. /**
  65295. * Teleport the agent to a new position
  65296. * @param index agent index returned by addAgent
  65297. * @param destination targeted world position
  65298. */
  65299. agentTeleport(index: number, destination: Vector3): void;
  65300. /**
  65301. * Update agent parameters
  65302. * @param index agent index returned by addAgent
  65303. * @param parameters agent parameters
  65304. */
  65305. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65306. /**
  65307. * remove a particular agent previously created
  65308. * @param index agent index returned by addAgent
  65309. */
  65310. removeAgent(index: number): void;
  65311. /**
  65312. * get the list of all agents attached to this crowd
  65313. * @returns list of agent indices
  65314. */
  65315. getAgents(): number[];
  65316. /**
  65317. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65318. * @param deltaTime in seconds
  65319. */
  65320. update(deltaTime: number): void;
  65321. /**
  65322. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65323. * The queries will try to find a solution within those bounds
  65324. * default is (1,1,1)
  65325. * @param extent x,y,z value that define the extent around the queries point of reference
  65326. */
  65327. setDefaultQueryExtent(extent: Vector3): void;
  65328. /**
  65329. * Get the Bounding box extent specified by setDefaultQueryExtent
  65330. * @returns the box extent values
  65331. */
  65332. getDefaultQueryExtent(): Vector3;
  65333. /**
  65334. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65335. * @param result output the box extent values
  65336. */
  65337. getDefaultQueryExtentToRef(result: Vector3): void;
  65338. /**
  65339. * Release all resources
  65340. */
  65341. dispose(): void;
  65342. }
  65343. }
  65344. declare module BABYLON {
  65345. /**
  65346. * Class used to enable access to IndexedDB
  65347. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  65348. */
  65349. export class Database implements IOfflineProvider {
  65350. private _callbackManifestChecked;
  65351. private _currentSceneUrl;
  65352. private _db;
  65353. private _enableSceneOffline;
  65354. private _enableTexturesOffline;
  65355. private _manifestVersionFound;
  65356. private _mustUpdateRessources;
  65357. private _hasReachedQuota;
  65358. private _isSupported;
  65359. private _idbFactory;
  65360. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  65361. private static IsUASupportingBlobStorage;
  65362. /**
  65363. * Gets a boolean indicating if Database storate is enabled (off by default)
  65364. */
  65365. static IDBStorageEnabled: boolean;
  65366. /**
  65367. * Gets a boolean indicating if scene must be saved in the database
  65368. */
  65369. get enableSceneOffline(): boolean;
  65370. /**
  65371. * Gets a boolean indicating if textures must be saved in the database
  65372. */
  65373. get enableTexturesOffline(): boolean;
  65374. /**
  65375. * Creates a new Database
  65376. * @param urlToScene defines the url to load the scene
  65377. * @param callbackManifestChecked defines the callback to use when manifest is checked
  65378. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  65379. */
  65380. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  65381. private static _ParseURL;
  65382. private static _ReturnFullUrlLocation;
  65383. private _checkManifestFile;
  65384. /**
  65385. * Open the database and make it available
  65386. * @param successCallback defines the callback to call on success
  65387. * @param errorCallback defines the callback to call on error
  65388. */
  65389. open(successCallback: () => void, errorCallback: () => void): void;
  65390. /**
  65391. * Loads an image from the database
  65392. * @param url defines the url to load from
  65393. * @param image defines the target DOM image
  65394. */
  65395. loadImage(url: string, image: HTMLImageElement): void;
  65396. private _loadImageFromDBAsync;
  65397. private _saveImageIntoDBAsync;
  65398. private _checkVersionFromDB;
  65399. private _loadVersionFromDBAsync;
  65400. private _saveVersionIntoDBAsync;
  65401. /**
  65402. * Loads a file from database
  65403. * @param url defines the URL to load from
  65404. * @param sceneLoaded defines a callback to call on success
  65405. * @param progressCallBack defines a callback to call when progress changed
  65406. * @param errorCallback defines a callback to call on error
  65407. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  65408. */
  65409. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  65410. private _loadFileAsync;
  65411. private _saveFileAsync;
  65412. /**
  65413. * Validates if xhr data is correct
  65414. * @param xhr defines the request to validate
  65415. * @param dataType defines the expected data type
  65416. * @returns true if data is correct
  65417. */
  65418. private static _ValidateXHRData;
  65419. }
  65420. }
  65421. declare module BABYLON {
  65422. /** @hidden */
  65423. export var gpuUpdateParticlesPixelShader: {
  65424. name: string;
  65425. shader: string;
  65426. };
  65427. }
  65428. declare module BABYLON {
  65429. /** @hidden */
  65430. export var gpuUpdateParticlesVertexShader: {
  65431. name: string;
  65432. shader: string;
  65433. };
  65434. }
  65435. declare module BABYLON {
  65436. /** @hidden */
  65437. export var clipPlaneFragmentDeclaration2: {
  65438. name: string;
  65439. shader: string;
  65440. };
  65441. }
  65442. declare module BABYLON {
  65443. /** @hidden */
  65444. export var gpuRenderParticlesPixelShader: {
  65445. name: string;
  65446. shader: string;
  65447. };
  65448. }
  65449. declare module BABYLON {
  65450. /** @hidden */
  65451. export var clipPlaneVertexDeclaration2: {
  65452. name: string;
  65453. shader: string;
  65454. };
  65455. }
  65456. declare module BABYLON {
  65457. /** @hidden */
  65458. export var gpuRenderParticlesVertexShader: {
  65459. name: string;
  65460. shader: string;
  65461. };
  65462. }
  65463. declare module BABYLON {
  65464. /**
  65465. * This represents a GPU particle system in Babylon
  65466. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  65467. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  65468. */
  65469. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  65470. /**
  65471. * The layer mask we are rendering the particles through.
  65472. */
  65473. layerMask: number;
  65474. private _capacity;
  65475. private _activeCount;
  65476. private _currentActiveCount;
  65477. private _accumulatedCount;
  65478. private _renderEffect;
  65479. private _updateEffect;
  65480. private _buffer0;
  65481. private _buffer1;
  65482. private _spriteBuffer;
  65483. private _updateVAO;
  65484. private _renderVAO;
  65485. private _targetIndex;
  65486. private _sourceBuffer;
  65487. private _targetBuffer;
  65488. private _engine;
  65489. private _currentRenderId;
  65490. private _started;
  65491. private _stopped;
  65492. private _timeDelta;
  65493. private _randomTexture;
  65494. private _randomTexture2;
  65495. private _attributesStrideSize;
  65496. private _updateEffectOptions;
  65497. private _randomTextureSize;
  65498. private _actualFrame;
  65499. private _customEffect;
  65500. private readonly _rawTextureWidth;
  65501. /**
  65502. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  65503. */
  65504. static get IsSupported(): boolean;
  65505. /**
  65506. * An event triggered when the system is disposed.
  65507. */
  65508. onDisposeObservable: Observable<IParticleSystem>;
  65509. /**
  65510. * Gets the maximum number of particles active at the same time.
  65511. * @returns The max number of active particles.
  65512. */
  65513. getCapacity(): number;
  65514. /**
  65515. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  65516. * to override the particles.
  65517. */
  65518. forceDepthWrite: boolean;
  65519. /**
  65520. * Gets or set the number of active particles
  65521. */
  65522. get activeParticleCount(): number;
  65523. set activeParticleCount(value: number);
  65524. private _preWarmDone;
  65525. /**
  65526. * Specifies if the particles are updated in emitter local space or world space.
  65527. */
  65528. isLocal: boolean;
  65529. /**
  65530. * Is this system ready to be used/rendered
  65531. * @return true if the system is ready
  65532. */
  65533. isReady(): boolean;
  65534. /**
  65535. * Gets if the system has been started. (Note: this will still be true after stop is called)
  65536. * @returns True if it has been started, otherwise false.
  65537. */
  65538. isStarted(): boolean;
  65539. /**
  65540. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  65541. * @returns True if it has been stopped, otherwise false.
  65542. */
  65543. isStopped(): boolean;
  65544. /**
  65545. * Gets a boolean indicating that the system is stopping
  65546. * @returns true if the system is currently stopping
  65547. */
  65548. isStopping(): boolean;
  65549. /**
  65550. * Gets the number of particles active at the same time.
  65551. * @returns The number of active particles.
  65552. */
  65553. getActiveCount(): number;
  65554. /**
  65555. * Starts the particle system and begins to emit
  65556. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  65557. */
  65558. start(delay?: number): void;
  65559. /**
  65560. * Stops the particle system.
  65561. */
  65562. stop(): void;
  65563. /**
  65564. * Remove all active particles
  65565. */
  65566. reset(): void;
  65567. /**
  65568. * Returns the string "GPUParticleSystem"
  65569. * @returns a string containing the class name
  65570. */
  65571. getClassName(): string;
  65572. /**
  65573. * Gets the custom effect used to render the particles
  65574. * @param blendMode Blend mode for which the effect should be retrieved
  65575. * @returns The effect
  65576. */
  65577. getCustomEffect(blendMode?: number): Nullable<Effect>;
  65578. /**
  65579. * Sets the custom effect used to render the particles
  65580. * @param effect The effect to set
  65581. * @param blendMode Blend mode for which the effect should be set
  65582. */
  65583. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  65584. /** @hidden */
  65585. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  65586. /**
  65587. * Observable that will be called just before the particles are drawn
  65588. */
  65589. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  65590. /**
  65591. * Gets the name of the particle vertex shader
  65592. */
  65593. get vertexShaderName(): string;
  65594. private _colorGradientsTexture;
  65595. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  65596. /**
  65597. * Adds a new color gradient
  65598. * @param gradient defines the gradient to use (between 0 and 1)
  65599. * @param color1 defines the color to affect to the specified gradient
  65600. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  65601. * @returns the current particle system
  65602. */
  65603. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  65604. private _refreshColorGradient;
  65605. /** Force the system to rebuild all gradients that need to be resync */
  65606. forceRefreshGradients(): void;
  65607. /**
  65608. * Remove a specific color gradient
  65609. * @param gradient defines the gradient to remove
  65610. * @returns the current particle system
  65611. */
  65612. removeColorGradient(gradient: number): GPUParticleSystem;
  65613. private _angularSpeedGradientsTexture;
  65614. private _sizeGradientsTexture;
  65615. private _velocityGradientsTexture;
  65616. private _limitVelocityGradientsTexture;
  65617. private _dragGradientsTexture;
  65618. private _addFactorGradient;
  65619. /**
  65620. * Adds a new size gradient
  65621. * @param gradient defines the gradient to use (between 0 and 1)
  65622. * @param factor defines the size factor to affect to the specified gradient
  65623. * @returns the current particle system
  65624. */
  65625. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  65626. /**
  65627. * Remove a specific size gradient
  65628. * @param gradient defines the gradient to remove
  65629. * @returns the current particle system
  65630. */
  65631. removeSizeGradient(gradient: number): GPUParticleSystem;
  65632. private _refreshFactorGradient;
  65633. /**
  65634. * Adds a new angular speed gradient
  65635. * @param gradient defines the gradient to use (between 0 and 1)
  65636. * @param factor defines the angular speed to affect to the specified gradient
  65637. * @returns the current particle system
  65638. */
  65639. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  65640. /**
  65641. * Remove a specific angular speed gradient
  65642. * @param gradient defines the gradient to remove
  65643. * @returns the current particle system
  65644. */
  65645. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  65646. /**
  65647. * Adds a new velocity gradient
  65648. * @param gradient defines the gradient to use (between 0 and 1)
  65649. * @param factor defines the velocity to affect to the specified gradient
  65650. * @returns the current particle system
  65651. */
  65652. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65653. /**
  65654. * Remove a specific velocity gradient
  65655. * @param gradient defines the gradient to remove
  65656. * @returns the current particle system
  65657. */
  65658. removeVelocityGradient(gradient: number): GPUParticleSystem;
  65659. /**
  65660. * Adds a new limit velocity gradient
  65661. * @param gradient defines the gradient to use (between 0 and 1)
  65662. * @param factor defines the limit velocity value to affect to the specified gradient
  65663. * @returns the current particle system
  65664. */
  65665. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65666. /**
  65667. * Remove a specific limit velocity gradient
  65668. * @param gradient defines the gradient to remove
  65669. * @returns the current particle system
  65670. */
  65671. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  65672. /**
  65673. * Adds a new drag gradient
  65674. * @param gradient defines the gradient to use (between 0 and 1)
  65675. * @param factor defines the drag value to affect to the specified gradient
  65676. * @returns the current particle system
  65677. */
  65678. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  65679. /**
  65680. * Remove a specific drag gradient
  65681. * @param gradient defines the gradient to remove
  65682. * @returns the current particle system
  65683. */
  65684. removeDragGradient(gradient: number): GPUParticleSystem;
  65685. /**
  65686. * Not supported by GPUParticleSystem
  65687. * @param gradient defines the gradient to use (between 0 and 1)
  65688. * @param factor defines the emit rate value to affect to the specified gradient
  65689. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65690. * @returns the current particle system
  65691. */
  65692. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65693. /**
  65694. * Not supported by GPUParticleSystem
  65695. * @param gradient defines the gradient to remove
  65696. * @returns the current particle system
  65697. */
  65698. removeEmitRateGradient(gradient: number): IParticleSystem;
  65699. /**
  65700. * Not supported by GPUParticleSystem
  65701. * @param gradient defines the gradient to use (between 0 and 1)
  65702. * @param factor defines the start size value to affect to the specified gradient
  65703. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65704. * @returns the current particle system
  65705. */
  65706. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65707. /**
  65708. * Not supported by GPUParticleSystem
  65709. * @param gradient defines the gradient to remove
  65710. * @returns the current particle system
  65711. */
  65712. removeStartSizeGradient(gradient: number): IParticleSystem;
  65713. /**
  65714. * Not supported by GPUParticleSystem
  65715. * @param gradient defines the gradient to use (between 0 and 1)
  65716. * @param min defines the color remap minimal range
  65717. * @param max defines the color remap maximal range
  65718. * @returns the current particle system
  65719. */
  65720. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65721. /**
  65722. * Not supported by GPUParticleSystem
  65723. * @param gradient defines the gradient to remove
  65724. * @returns the current particle system
  65725. */
  65726. removeColorRemapGradient(): IParticleSystem;
  65727. /**
  65728. * Not supported by GPUParticleSystem
  65729. * @param gradient defines the gradient to use (between 0 and 1)
  65730. * @param min defines the alpha remap minimal range
  65731. * @param max defines the alpha remap maximal range
  65732. * @returns the current particle system
  65733. */
  65734. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65735. /**
  65736. * Not supported by GPUParticleSystem
  65737. * @param gradient defines the gradient to remove
  65738. * @returns the current particle system
  65739. */
  65740. removeAlphaRemapGradient(): IParticleSystem;
  65741. /**
  65742. * Not supported by GPUParticleSystem
  65743. * @param gradient defines the gradient to use (between 0 and 1)
  65744. * @param color defines the color to affect to the specified gradient
  65745. * @returns the current particle system
  65746. */
  65747. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  65748. /**
  65749. * Not supported by GPUParticleSystem
  65750. * @param gradient defines the gradient to remove
  65751. * @returns the current particle system
  65752. */
  65753. removeRampGradient(): IParticleSystem;
  65754. /**
  65755. * Not supported by GPUParticleSystem
  65756. * @returns the list of ramp gradients
  65757. */
  65758. getRampGradients(): Nullable<Array<Color3Gradient>>;
  65759. /**
  65760. * Not supported by GPUParticleSystem
  65761. * Gets or sets a boolean indicating that ramp gradients must be used
  65762. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  65763. */
  65764. get useRampGradients(): boolean;
  65765. set useRampGradients(value: boolean);
  65766. /**
  65767. * Not supported by GPUParticleSystem
  65768. * @param gradient defines the gradient to use (between 0 and 1)
  65769. * @param factor defines the life time factor to affect to the specified gradient
  65770. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65771. * @returns the current particle system
  65772. */
  65773. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65774. /**
  65775. * Not supported by GPUParticleSystem
  65776. * @param gradient defines the gradient to remove
  65777. * @returns the current particle system
  65778. */
  65779. removeLifeTimeGradient(gradient: number): IParticleSystem;
  65780. /**
  65781. * Instantiates a GPU particle system.
  65782. * 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.
  65783. * @param name The name of the particle system
  65784. * @param options The options used to create the system
  65785. * @param scene The scene the particle system belongs to
  65786. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  65787. * @param customEffect a custom effect used to change the way particles are rendered by default
  65788. */
  65789. constructor(name: string, options: Partial<{
  65790. capacity: number;
  65791. randomTextureSize: number;
  65792. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  65793. protected _reset(): void;
  65794. private _createUpdateVAO;
  65795. private _createRenderVAO;
  65796. private _initialize;
  65797. /** @hidden */
  65798. _recreateUpdateEffect(): void;
  65799. private _getEffect;
  65800. /**
  65801. * Fill the defines array according to the current settings of the particle system
  65802. * @param defines Array to be updated
  65803. * @param blendMode blend mode to take into account when updating the array
  65804. */
  65805. fillDefines(defines: Array<string>, blendMode?: number): void;
  65806. /**
  65807. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  65808. * @param uniforms Uniforms array to fill
  65809. * @param attributes Attributes array to fill
  65810. * @param samplers Samplers array to fill
  65811. */
  65812. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  65813. /** @hidden */
  65814. _recreateRenderEffect(): Effect;
  65815. /**
  65816. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  65817. * @param preWarm defines if we are in the pre-warmimg phase
  65818. */
  65819. animate(preWarm?: boolean): void;
  65820. private _createFactorGradientTexture;
  65821. private _createSizeGradientTexture;
  65822. private _createAngularSpeedGradientTexture;
  65823. private _createVelocityGradientTexture;
  65824. private _createLimitVelocityGradientTexture;
  65825. private _createDragGradientTexture;
  65826. private _createColorGradientTexture;
  65827. /**
  65828. * Renders the particle system in its current state
  65829. * @param preWarm defines if the system should only update the particles but not render them
  65830. * @returns the current number of particles
  65831. */
  65832. render(preWarm?: boolean): number;
  65833. /**
  65834. * Rebuilds the particle system
  65835. */
  65836. rebuild(): void;
  65837. private _releaseBuffers;
  65838. private _releaseVAOs;
  65839. /**
  65840. * Disposes the particle system and free the associated resources
  65841. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  65842. */
  65843. dispose(disposeTexture?: boolean): void;
  65844. /**
  65845. * Clones the particle system.
  65846. * @param name The name of the cloned object
  65847. * @param newEmitter The new emitter to use
  65848. * @returns the cloned particle system
  65849. */
  65850. clone(name: string, newEmitter: any): GPUParticleSystem;
  65851. /**
  65852. * Serializes the particle system to a JSON object
  65853. * @param serializeTexture defines if the texture must be serialized as well
  65854. * @returns the JSON object
  65855. */
  65856. serialize(serializeTexture?: boolean): any;
  65857. /**
  65858. * Parses a JSON object to create a GPU particle system.
  65859. * @param parsedParticleSystem The JSON object to parse
  65860. * @param scene The scene to create the particle system in
  65861. * @param rootUrl The root url to use to load external dependencies like texture
  65862. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  65863. * @returns the parsed GPU particle system
  65864. */
  65865. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  65866. }
  65867. }
  65868. declare module BABYLON {
  65869. /**
  65870. * Represents a set of particle systems working together to create a specific effect
  65871. */
  65872. export class ParticleSystemSet implements IDisposable {
  65873. /**
  65874. * Gets or sets base Assets URL
  65875. */
  65876. static BaseAssetsUrl: string;
  65877. private _emitterCreationOptions;
  65878. private _emitterNode;
  65879. /**
  65880. * Gets the particle system list
  65881. */
  65882. systems: IParticleSystem[];
  65883. /**
  65884. * Gets the emitter node used with this set
  65885. */
  65886. get emitterNode(): Nullable<TransformNode>;
  65887. /**
  65888. * Creates a new emitter mesh as a sphere
  65889. * @param options defines the options used to create the sphere
  65890. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  65891. * @param scene defines the hosting scene
  65892. */
  65893. setEmitterAsSphere(options: {
  65894. diameter: number;
  65895. segments: number;
  65896. color: Color3;
  65897. }, renderingGroupId: number, scene: Scene): void;
  65898. /**
  65899. * Starts all particle systems of the set
  65900. * @param emitter defines an optional mesh to use as emitter for the particle systems
  65901. */
  65902. start(emitter?: AbstractMesh): void;
  65903. /**
  65904. * Release all associated resources
  65905. */
  65906. dispose(): void;
  65907. /**
  65908. * Serialize the set into a JSON compatible object
  65909. * @param serializeTexture defines if the texture must be serialized as well
  65910. * @returns a JSON compatible representation of the set
  65911. */
  65912. serialize(serializeTexture?: boolean): any;
  65913. /**
  65914. * Parse a new ParticleSystemSet from a serialized source
  65915. * @param data defines a JSON compatible representation of the set
  65916. * @param scene defines the hosting scene
  65917. * @param gpu defines if we want GPU particles or CPU particles
  65918. * @returns a new ParticleSystemSet
  65919. */
  65920. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  65921. }
  65922. }
  65923. declare module BABYLON {
  65924. /**
  65925. * This class is made for on one-liner static method to help creating particle system set.
  65926. */
  65927. export class ParticleHelper {
  65928. /**
  65929. * Gets or sets base Assets URL
  65930. */
  65931. static BaseAssetsUrl: string;
  65932. /** Define the Url to load snippets */
  65933. static SnippetUrl: string;
  65934. /**
  65935. * Create a default particle system that you can tweak
  65936. * @param emitter defines the emitter to use
  65937. * @param capacity defines the system capacity (default is 500 particles)
  65938. * @param scene defines the hosting scene
  65939. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  65940. * @returns the new Particle system
  65941. */
  65942. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  65943. /**
  65944. * This is the main static method (one-liner) of this helper to create different particle systems
  65945. * @param type This string represents the type to the particle system to create
  65946. * @param scene The scene where the particle system should live
  65947. * @param gpu If the system will use gpu
  65948. * @returns the ParticleSystemSet created
  65949. */
  65950. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  65951. /**
  65952. * Static function used to export a particle system to a ParticleSystemSet variable.
  65953. * Please note that the emitter shape is not exported
  65954. * @param systems defines the particle systems to export
  65955. * @returns the created particle system set
  65956. */
  65957. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  65958. /**
  65959. * Creates a particle system from a snippet saved in a remote file
  65960. * @param name defines the name of the particle system to create
  65961. * @param url defines the url to load from
  65962. * @param scene defines the hosting scene
  65963. * @param gpu If the system will use gpu
  65964. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  65965. * @returns a promise that will resolve to the new particle system
  65966. */
  65967. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  65968. /**
  65969. * Creates a particle system from a snippet saved by the particle system editor
  65970. * @param snippetId defines the snippet to load
  65971. * @param scene defines the hosting scene
  65972. * @param gpu If the system will use gpu
  65973. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  65974. * @returns a promise that will resolve to the new particle system
  65975. */
  65976. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  65977. }
  65978. }
  65979. declare module BABYLON {
  65980. interface Engine {
  65981. /**
  65982. * Create an effect to use with particle systems.
  65983. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  65984. * the particle system for which you want to create a custom effect in the last parameter
  65985. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  65986. * @param uniformsNames defines a list of attribute names
  65987. * @param samplers defines an array of string used to represent textures
  65988. * @param defines defines the string containing the defines to use to compile the shaders
  65989. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  65990. * @param onCompiled defines a function to call when the effect creation is successful
  65991. * @param onError defines a function to call when the effect creation has failed
  65992. * @param particleSystem the particle system you want to create the effect for
  65993. * @returns the new Effect
  65994. */
  65995. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  65996. }
  65997. interface Mesh {
  65998. /**
  65999. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66000. * @returns an array of IParticleSystem
  66001. */
  66002. getEmittedParticleSystems(): IParticleSystem[];
  66003. /**
  66004. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66005. * @returns an array of IParticleSystem
  66006. */
  66007. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66008. }
  66009. /**
  66010. * @hidden
  66011. */
  66012. export var _IDoNeedToBeInTheBuild: number;
  66013. }
  66014. declare module BABYLON {
  66015. /** Defines the 4 color options */
  66016. export enum PointColor {
  66017. /** color value */
  66018. Color = 2,
  66019. /** uv value */
  66020. UV = 1,
  66021. /** random value */
  66022. Random = 0,
  66023. /** stated value */
  66024. Stated = 3
  66025. }
  66026. /**
  66027. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66028. * 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.
  66029. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66030. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66031. *
  66032. * Full documentation here : TO BE ENTERED
  66033. */
  66034. export class PointsCloudSystem implements IDisposable {
  66035. /**
  66036. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66037. * Example : var p = SPS.particles[i];
  66038. */
  66039. particles: CloudPoint[];
  66040. /**
  66041. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66042. */
  66043. nbParticles: number;
  66044. /**
  66045. * This a counter for your own usage. It's not set by any SPS functions.
  66046. */
  66047. counter: number;
  66048. /**
  66049. * The PCS name. This name is also given to the underlying mesh.
  66050. */
  66051. name: string;
  66052. /**
  66053. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66054. */
  66055. mesh: Mesh;
  66056. /**
  66057. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66058. * Please read :
  66059. */
  66060. vars: any;
  66061. /**
  66062. * @hidden
  66063. */
  66064. _size: number;
  66065. private _scene;
  66066. private _promises;
  66067. private _positions;
  66068. private _indices;
  66069. private _normals;
  66070. private _colors;
  66071. private _uvs;
  66072. private _indices32;
  66073. private _positions32;
  66074. private _colors32;
  66075. private _uvs32;
  66076. private _updatable;
  66077. private _isVisibilityBoxLocked;
  66078. private _alwaysVisible;
  66079. private _groups;
  66080. private _groupCounter;
  66081. private _computeParticleColor;
  66082. private _computeParticleTexture;
  66083. private _computeParticleRotation;
  66084. private _computeBoundingBox;
  66085. private _isReady;
  66086. /**
  66087. * Creates a PCS (Points Cloud System) object
  66088. * @param name (String) is the PCS name, this will be the underlying mesh name
  66089. * @param pointSize (number) is the size for each point
  66090. * @param scene (Scene) is the scene in which the PCS is added
  66091. * @param options defines the options of the PCS e.g.
  66092. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66093. */
  66094. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66095. updatable?: boolean;
  66096. });
  66097. /**
  66098. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66099. * If no points were added to the PCS, the returned mesh is just a single point.
  66100. * @returns a promise for the created mesh
  66101. */
  66102. buildMeshAsync(): Promise<Mesh>;
  66103. /**
  66104. * @hidden
  66105. */
  66106. private _buildMesh;
  66107. private _addParticle;
  66108. private _randomUnitVector;
  66109. private _getColorIndicesForCoord;
  66110. private _setPointsColorOrUV;
  66111. private _colorFromTexture;
  66112. private _calculateDensity;
  66113. /**
  66114. * Adds points to the PCS in random positions within a unit sphere
  66115. * @param nb (positive integer) the number of particles to be created from this model
  66116. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  66117. * @returns the number of groups in the system
  66118. */
  66119. addPoints(nb: number, pointFunction?: any): number;
  66120. /**
  66121. * Adds points to the PCS from the surface of the model shape
  66122. * @param mesh is any Mesh object that will be used as a surface model for the points
  66123. * @param nb (positive integer) the number of particles to be created from this model
  66124. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66125. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66126. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66127. * @returns the number of groups in the system
  66128. */
  66129. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66130. /**
  66131. * Adds points to the PCS inside the model shape
  66132. * @param mesh is any Mesh object that will be used as a surface model for the points
  66133. * @param nb (positive integer) the number of particles to be created from this model
  66134. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66135. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66136. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66137. * @returns the number of groups in the system
  66138. */
  66139. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66140. /**
  66141. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  66142. * This method calls `updateParticle()` for each particle of the SPS.
  66143. * For an animated SPS, it is usually called within the render loop.
  66144. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  66145. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  66146. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  66147. * @returns the PCS.
  66148. */
  66149. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  66150. /**
  66151. * Disposes the PCS.
  66152. */
  66153. dispose(): void;
  66154. /**
  66155. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  66156. * doc :
  66157. * @returns the PCS.
  66158. */
  66159. refreshVisibleSize(): PointsCloudSystem;
  66160. /**
  66161. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  66162. * @param size the size (float) of the visibility box
  66163. * note : this doesn't lock the PCS mesh bounding box.
  66164. * doc :
  66165. */
  66166. setVisibilityBox(size: number): void;
  66167. /**
  66168. * Gets whether the PCS is always visible or not
  66169. * doc :
  66170. */
  66171. get isAlwaysVisible(): boolean;
  66172. /**
  66173. * Sets the PCS as always visible or not
  66174. * doc :
  66175. */
  66176. set isAlwaysVisible(val: boolean);
  66177. /**
  66178. * Tells to `setParticles()` to compute the particle rotations or not
  66179. * Default value : false. The PCS is faster when it's set to false
  66180. * Note : particle rotations are only applied to parent particles
  66181. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  66182. */
  66183. set computeParticleRotation(val: boolean);
  66184. /**
  66185. * Tells to `setParticles()` to compute the particle colors or not.
  66186. * Default value : true. The PCS is faster when it's set to false.
  66187. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66188. */
  66189. set computeParticleColor(val: boolean);
  66190. set computeParticleTexture(val: boolean);
  66191. /**
  66192. * Gets if `setParticles()` computes the particle colors or not.
  66193. * Default value : false. The PCS is faster when it's set to false.
  66194. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66195. */
  66196. get computeParticleColor(): boolean;
  66197. /**
  66198. * Gets if `setParticles()` computes the particle textures or not.
  66199. * Default value : false. The PCS is faster when it's set to false.
  66200. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  66201. */
  66202. get computeParticleTexture(): boolean;
  66203. /**
  66204. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  66205. */
  66206. set computeBoundingBox(val: boolean);
  66207. /**
  66208. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  66209. */
  66210. get computeBoundingBox(): boolean;
  66211. /**
  66212. * This function does nothing. It may be overwritten to set all the particle first values.
  66213. * The PCS doesn't call this function, you may have to call it by your own.
  66214. * doc :
  66215. */
  66216. initParticles(): void;
  66217. /**
  66218. * This function does nothing. It may be overwritten to recycle a particle
  66219. * The PCS doesn't call this function, you can to call it
  66220. * doc :
  66221. * @param particle The particle to recycle
  66222. * @returns the recycled particle
  66223. */
  66224. recycleParticle(particle: CloudPoint): CloudPoint;
  66225. /**
  66226. * Updates a particle : this function should be overwritten by the user.
  66227. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  66228. * doc :
  66229. * @example : just set a particle position or velocity and recycle conditions
  66230. * @param particle The particle to update
  66231. * @returns the updated particle
  66232. */
  66233. updateParticle(particle: CloudPoint): CloudPoint;
  66234. /**
  66235. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  66236. * This does nothing and may be overwritten by the user.
  66237. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66238. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66239. * @param update the boolean update value actually passed to setParticles()
  66240. */
  66241. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66242. /**
  66243. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  66244. * This will be passed three parameters.
  66245. * This does nothing and may be overwritten by the user.
  66246. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66247. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66248. * @param update the boolean update value actually passed to setParticles()
  66249. */
  66250. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66251. }
  66252. }
  66253. declare module BABYLON {
  66254. /**
  66255. * Represents one particle of a points cloud system.
  66256. */
  66257. export class CloudPoint {
  66258. /**
  66259. * particle global index
  66260. */
  66261. idx: number;
  66262. /**
  66263. * The color of the particle
  66264. */
  66265. color: Nullable<Color4>;
  66266. /**
  66267. * The world space position of the particle.
  66268. */
  66269. position: Vector3;
  66270. /**
  66271. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  66272. */
  66273. rotation: Vector3;
  66274. /**
  66275. * The world space rotation quaternion of the particle.
  66276. */
  66277. rotationQuaternion: Nullable<Quaternion>;
  66278. /**
  66279. * The uv of the particle.
  66280. */
  66281. uv: Nullable<Vector2>;
  66282. /**
  66283. * The current speed of the particle.
  66284. */
  66285. velocity: Vector3;
  66286. /**
  66287. * The pivot point in the particle local space.
  66288. */
  66289. pivot: Vector3;
  66290. /**
  66291. * Must the particle be translated from its pivot point in its local space ?
  66292. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  66293. * Default : false
  66294. */
  66295. translateFromPivot: boolean;
  66296. /**
  66297. * Index of this particle in the global "positions" array (Internal use)
  66298. * @hidden
  66299. */
  66300. _pos: number;
  66301. /**
  66302. * @hidden Index of this particle in the global "indices" array (Internal use)
  66303. */
  66304. _ind: number;
  66305. /**
  66306. * Group this particle belongs to
  66307. */
  66308. _group: PointsGroup;
  66309. /**
  66310. * Group id of this particle
  66311. */
  66312. groupId: number;
  66313. /**
  66314. * Index of the particle in its group id (Internal use)
  66315. */
  66316. idxInGroup: number;
  66317. /**
  66318. * @hidden Particle BoundingInfo object (Internal use)
  66319. */
  66320. _boundingInfo: BoundingInfo;
  66321. /**
  66322. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  66323. */
  66324. _pcs: PointsCloudSystem;
  66325. /**
  66326. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  66327. */
  66328. _stillInvisible: boolean;
  66329. /**
  66330. * @hidden Last computed particle rotation matrix
  66331. */
  66332. _rotationMatrix: number[];
  66333. /**
  66334. * Parent particle Id, if any.
  66335. * Default null.
  66336. */
  66337. parentId: Nullable<number>;
  66338. /**
  66339. * @hidden Internal global position in the PCS.
  66340. */
  66341. _globalPosition: Vector3;
  66342. /**
  66343. * Creates a Point Cloud object.
  66344. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  66345. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  66346. * @param group (PointsGroup) is the group the particle belongs to
  66347. * @param groupId (integer) is the group identifier in the PCS.
  66348. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  66349. * @param pcs defines the PCS it is associated to
  66350. */
  66351. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  66352. /**
  66353. * get point size
  66354. */
  66355. get size(): Vector3;
  66356. /**
  66357. * Set point size
  66358. */
  66359. set size(scale: Vector3);
  66360. /**
  66361. * Legacy support, changed quaternion to rotationQuaternion
  66362. */
  66363. get quaternion(): Nullable<Quaternion>;
  66364. /**
  66365. * Legacy support, changed quaternion to rotationQuaternion
  66366. */
  66367. set quaternion(q: Nullable<Quaternion>);
  66368. /**
  66369. * Returns a boolean. True if the particle intersects a mesh, else false
  66370. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  66371. * @param target is the object (point or mesh) what the intersection is computed against
  66372. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  66373. * @returns true if it intersects
  66374. */
  66375. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  66376. /**
  66377. * get the rotation matrix of the particle
  66378. * @hidden
  66379. */
  66380. getRotationMatrix(m: Matrix): void;
  66381. }
  66382. /**
  66383. * Represents a group of points in a points cloud system
  66384. * * PCS internal tool, don't use it manually.
  66385. */
  66386. export class PointsGroup {
  66387. /**
  66388. * The group id
  66389. * @hidden
  66390. */
  66391. groupID: number;
  66392. /**
  66393. * image data for group (internal use)
  66394. * @hidden
  66395. */
  66396. _groupImageData: Nullable<ArrayBufferView>;
  66397. /**
  66398. * Image Width (internal use)
  66399. * @hidden
  66400. */
  66401. _groupImgWidth: number;
  66402. /**
  66403. * Image Height (internal use)
  66404. * @hidden
  66405. */
  66406. _groupImgHeight: number;
  66407. /**
  66408. * Custom position function (internal use)
  66409. * @hidden
  66410. */
  66411. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  66412. /**
  66413. * density per facet for surface points
  66414. * @hidden
  66415. */
  66416. _groupDensity: number[];
  66417. /**
  66418. * Only when points are colored by texture carries pointer to texture list array
  66419. * @hidden
  66420. */
  66421. _textureNb: number;
  66422. /**
  66423. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  66424. * PCS internal tool, don't use it manually.
  66425. * @hidden
  66426. */
  66427. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  66428. }
  66429. }
  66430. declare module BABYLON {
  66431. interface Scene {
  66432. /** @hidden (Backing field) */
  66433. _physicsEngine: Nullable<IPhysicsEngine>;
  66434. /** @hidden */
  66435. _physicsTimeAccumulator: number;
  66436. /**
  66437. * Gets the current physics engine
  66438. * @returns a IPhysicsEngine or null if none attached
  66439. */
  66440. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  66441. /**
  66442. * Enables physics to the current scene
  66443. * @param gravity defines the scene's gravity for the physics engine
  66444. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  66445. * @return a boolean indicating if the physics engine was initialized
  66446. */
  66447. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  66448. /**
  66449. * Disables and disposes the physics engine associated with the scene
  66450. */
  66451. disablePhysicsEngine(): void;
  66452. /**
  66453. * Gets a boolean indicating if there is an active physics engine
  66454. * @returns a boolean indicating if there is an active physics engine
  66455. */
  66456. isPhysicsEnabled(): boolean;
  66457. /**
  66458. * Deletes a physics compound impostor
  66459. * @param compound defines the compound to delete
  66460. */
  66461. deleteCompoundImpostor(compound: any): void;
  66462. /**
  66463. * An event triggered when physic simulation is about to be run
  66464. */
  66465. onBeforePhysicsObservable: Observable<Scene>;
  66466. /**
  66467. * An event triggered when physic simulation has been done
  66468. */
  66469. onAfterPhysicsObservable: Observable<Scene>;
  66470. }
  66471. interface AbstractMesh {
  66472. /** @hidden */
  66473. _physicsImpostor: Nullable<PhysicsImpostor>;
  66474. /**
  66475. * Gets or sets impostor used for physic simulation
  66476. * @see http://doc.babylonjs.com/features/physics_engine
  66477. */
  66478. physicsImpostor: Nullable<PhysicsImpostor>;
  66479. /**
  66480. * Gets the current physics impostor
  66481. * @see http://doc.babylonjs.com/features/physics_engine
  66482. * @returns a physics impostor or null
  66483. */
  66484. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  66485. /** Apply a physic impulse to the mesh
  66486. * @param force defines the force to apply
  66487. * @param contactPoint defines where to apply the force
  66488. * @returns the current mesh
  66489. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  66490. */
  66491. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  66492. /**
  66493. * Creates a physic joint between two meshes
  66494. * @param otherMesh defines the other mesh to use
  66495. * @param pivot1 defines the pivot to use on this mesh
  66496. * @param pivot2 defines the pivot to use on the other mesh
  66497. * @param options defines additional options (can be plugin dependent)
  66498. * @returns the current mesh
  66499. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  66500. */
  66501. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  66502. /** @hidden */
  66503. _disposePhysicsObserver: Nullable<Observer<Node>>;
  66504. }
  66505. /**
  66506. * Defines the physics engine scene component responsible to manage a physics engine
  66507. */
  66508. export class PhysicsEngineSceneComponent implements ISceneComponent {
  66509. /**
  66510. * The component name helpful to identify the component in the list of scene components.
  66511. */
  66512. readonly name: string;
  66513. /**
  66514. * The scene the component belongs to.
  66515. */
  66516. scene: Scene;
  66517. /**
  66518. * Creates a new instance of the component for the given scene
  66519. * @param scene Defines the scene to register the component in
  66520. */
  66521. constructor(scene: Scene);
  66522. /**
  66523. * Registers the component in a given scene
  66524. */
  66525. register(): void;
  66526. /**
  66527. * Rebuilds the elements related to this component in case of
  66528. * context lost for instance.
  66529. */
  66530. rebuild(): void;
  66531. /**
  66532. * Disposes the component and the associated ressources
  66533. */
  66534. dispose(): void;
  66535. }
  66536. }
  66537. declare module BABYLON {
  66538. /**
  66539. * A helper for physics simulations
  66540. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66541. */
  66542. export class PhysicsHelper {
  66543. private _scene;
  66544. private _physicsEngine;
  66545. /**
  66546. * Initializes the Physics helper
  66547. * @param scene Babylon.js scene
  66548. */
  66549. constructor(scene: Scene);
  66550. /**
  66551. * Applies a radial explosion impulse
  66552. * @param origin the origin of the explosion
  66553. * @param radiusOrEventOptions the radius or the options of radial explosion
  66554. * @param strength the explosion strength
  66555. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66556. * @returns A physics radial explosion event, or null
  66557. */
  66558. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66559. /**
  66560. * Applies a radial explosion force
  66561. * @param origin the origin of the explosion
  66562. * @param radiusOrEventOptions the radius or the options of radial explosion
  66563. * @param strength the explosion strength
  66564. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66565. * @returns A physics radial explosion event, or null
  66566. */
  66567. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66568. /**
  66569. * Creates a gravitational field
  66570. * @param origin the origin of the explosion
  66571. * @param radiusOrEventOptions the radius or the options of radial explosion
  66572. * @param strength the explosion strength
  66573. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66574. * @returns A physics gravitational field event, or null
  66575. */
  66576. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  66577. /**
  66578. * Creates a physics updraft event
  66579. * @param origin the origin of the updraft
  66580. * @param radiusOrEventOptions the radius or the options of the updraft
  66581. * @param strength the strength of the updraft
  66582. * @param height the height of the updraft
  66583. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  66584. * @returns A physics updraft event, or null
  66585. */
  66586. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  66587. /**
  66588. * Creates a physics vortex event
  66589. * @param origin the of the vortex
  66590. * @param radiusOrEventOptions the radius or the options of the vortex
  66591. * @param strength the strength of the vortex
  66592. * @param height the height of the vortex
  66593. * @returns a Physics vortex event, or null
  66594. * A physics vortex event or null
  66595. */
  66596. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  66597. }
  66598. /**
  66599. * Represents a physics radial explosion event
  66600. */
  66601. class PhysicsRadialExplosionEvent {
  66602. private _scene;
  66603. private _options;
  66604. private _sphere;
  66605. private _dataFetched;
  66606. /**
  66607. * Initializes a radial explosioin event
  66608. * @param _scene BabylonJS scene
  66609. * @param _options The options for the vortex event
  66610. */
  66611. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  66612. /**
  66613. * Returns the data related to the radial explosion event (sphere).
  66614. * @returns The radial explosion event data
  66615. */
  66616. getData(): PhysicsRadialExplosionEventData;
  66617. /**
  66618. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  66619. * @param impostor A physics imposter
  66620. * @param origin the origin of the explosion
  66621. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  66622. */
  66623. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  66624. /**
  66625. * Triggers affecterd impostors callbacks
  66626. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  66627. */
  66628. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  66629. /**
  66630. * Disposes the sphere.
  66631. * @param force Specifies if the sphere should be disposed by force
  66632. */
  66633. dispose(force?: boolean): void;
  66634. /*** Helpers ***/
  66635. private _prepareSphere;
  66636. private _intersectsWithSphere;
  66637. }
  66638. /**
  66639. * Represents a gravitational field event
  66640. */
  66641. class PhysicsGravitationalFieldEvent {
  66642. private _physicsHelper;
  66643. private _scene;
  66644. private _origin;
  66645. private _options;
  66646. private _tickCallback;
  66647. private _sphere;
  66648. private _dataFetched;
  66649. /**
  66650. * Initializes the physics gravitational field event
  66651. * @param _physicsHelper A physics helper
  66652. * @param _scene BabylonJS scene
  66653. * @param _origin The origin position of the gravitational field event
  66654. * @param _options The options for the vortex event
  66655. */
  66656. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  66657. /**
  66658. * Returns the data related to the gravitational field event (sphere).
  66659. * @returns A gravitational field event
  66660. */
  66661. getData(): PhysicsGravitationalFieldEventData;
  66662. /**
  66663. * Enables the gravitational field.
  66664. */
  66665. enable(): void;
  66666. /**
  66667. * Disables the gravitational field.
  66668. */
  66669. disable(): void;
  66670. /**
  66671. * Disposes the sphere.
  66672. * @param force The force to dispose from the gravitational field event
  66673. */
  66674. dispose(force?: boolean): void;
  66675. private _tick;
  66676. }
  66677. /**
  66678. * Represents a physics updraft event
  66679. */
  66680. class PhysicsUpdraftEvent {
  66681. private _scene;
  66682. private _origin;
  66683. private _options;
  66684. private _physicsEngine;
  66685. private _originTop;
  66686. private _originDirection;
  66687. private _tickCallback;
  66688. private _cylinder;
  66689. private _cylinderPosition;
  66690. private _dataFetched;
  66691. /**
  66692. * Initializes the physics updraft event
  66693. * @param _scene BabylonJS scene
  66694. * @param _origin The origin position of the updraft
  66695. * @param _options The options for the updraft event
  66696. */
  66697. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  66698. /**
  66699. * Returns the data related to the updraft event (cylinder).
  66700. * @returns A physics updraft event
  66701. */
  66702. getData(): PhysicsUpdraftEventData;
  66703. /**
  66704. * Enables the updraft.
  66705. */
  66706. enable(): void;
  66707. /**
  66708. * Disables the updraft.
  66709. */
  66710. disable(): void;
  66711. /**
  66712. * Disposes the cylinder.
  66713. * @param force Specifies if the updraft should be disposed by force
  66714. */
  66715. dispose(force?: boolean): void;
  66716. private getImpostorHitData;
  66717. private _tick;
  66718. /*** Helpers ***/
  66719. private _prepareCylinder;
  66720. private _intersectsWithCylinder;
  66721. }
  66722. /**
  66723. * Represents a physics vortex event
  66724. */
  66725. class PhysicsVortexEvent {
  66726. private _scene;
  66727. private _origin;
  66728. private _options;
  66729. private _physicsEngine;
  66730. private _originTop;
  66731. private _tickCallback;
  66732. private _cylinder;
  66733. private _cylinderPosition;
  66734. private _dataFetched;
  66735. /**
  66736. * Initializes the physics vortex event
  66737. * @param _scene The BabylonJS scene
  66738. * @param _origin The origin position of the vortex
  66739. * @param _options The options for the vortex event
  66740. */
  66741. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  66742. /**
  66743. * Returns the data related to the vortex event (cylinder).
  66744. * @returns The physics vortex event data
  66745. */
  66746. getData(): PhysicsVortexEventData;
  66747. /**
  66748. * Enables the vortex.
  66749. */
  66750. enable(): void;
  66751. /**
  66752. * Disables the cortex.
  66753. */
  66754. disable(): void;
  66755. /**
  66756. * Disposes the sphere.
  66757. * @param force
  66758. */
  66759. dispose(force?: boolean): void;
  66760. private getImpostorHitData;
  66761. private _tick;
  66762. /*** Helpers ***/
  66763. private _prepareCylinder;
  66764. private _intersectsWithCylinder;
  66765. }
  66766. /**
  66767. * Options fot the radial explosion event
  66768. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66769. */
  66770. export class PhysicsRadialExplosionEventOptions {
  66771. /**
  66772. * The radius of the sphere for the radial explosion.
  66773. */
  66774. radius: number;
  66775. /**
  66776. * The strenth of the explosion.
  66777. */
  66778. strength: number;
  66779. /**
  66780. * The strenght of the force in correspondence to the distance of the affected object
  66781. */
  66782. falloff: PhysicsRadialImpulseFalloff;
  66783. /**
  66784. * Sphere options for the radial explosion.
  66785. */
  66786. sphere: {
  66787. segments: number;
  66788. diameter: number;
  66789. };
  66790. /**
  66791. * Sphere options for the radial explosion.
  66792. */
  66793. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  66794. }
  66795. /**
  66796. * Options fot the updraft event
  66797. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66798. */
  66799. export class PhysicsUpdraftEventOptions {
  66800. /**
  66801. * The radius of the cylinder for the vortex
  66802. */
  66803. radius: number;
  66804. /**
  66805. * The strenth of the updraft.
  66806. */
  66807. strength: number;
  66808. /**
  66809. * The height of the cylinder for the updraft.
  66810. */
  66811. height: number;
  66812. /**
  66813. * The mode for the the updraft.
  66814. */
  66815. updraftMode: PhysicsUpdraftMode;
  66816. }
  66817. /**
  66818. * Options fot the vortex event
  66819. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66820. */
  66821. export class PhysicsVortexEventOptions {
  66822. /**
  66823. * The radius of the cylinder for the vortex
  66824. */
  66825. radius: number;
  66826. /**
  66827. * The strenth of the vortex.
  66828. */
  66829. strength: number;
  66830. /**
  66831. * The height of the cylinder for the vortex.
  66832. */
  66833. height: number;
  66834. /**
  66835. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  66836. */
  66837. centripetalForceThreshold: number;
  66838. /**
  66839. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  66840. */
  66841. centripetalForceMultiplier: number;
  66842. /**
  66843. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  66844. */
  66845. centrifugalForceMultiplier: number;
  66846. /**
  66847. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  66848. */
  66849. updraftForceMultiplier: number;
  66850. }
  66851. /**
  66852. * The strenght of the force in correspondence to the distance of the affected object
  66853. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66854. */
  66855. export enum PhysicsRadialImpulseFalloff {
  66856. /** Defines that impulse is constant in strength across it's whole radius */
  66857. Constant = 0,
  66858. /** Defines that impulse gets weaker if it's further from the origin */
  66859. Linear = 1
  66860. }
  66861. /**
  66862. * The strength of the force in correspondence to the distance of the affected object
  66863. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66864. */
  66865. export enum PhysicsUpdraftMode {
  66866. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  66867. Center = 0,
  66868. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  66869. Perpendicular = 1
  66870. }
  66871. /**
  66872. * Interface for a physics hit data
  66873. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66874. */
  66875. export interface PhysicsHitData {
  66876. /**
  66877. * The force applied at the contact point
  66878. */
  66879. force: Vector3;
  66880. /**
  66881. * The contact point
  66882. */
  66883. contactPoint: Vector3;
  66884. /**
  66885. * The distance from the origin to the contact point
  66886. */
  66887. distanceFromOrigin: number;
  66888. }
  66889. /**
  66890. * Interface for radial explosion event data
  66891. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66892. */
  66893. export interface PhysicsRadialExplosionEventData {
  66894. /**
  66895. * A sphere used for the radial explosion event
  66896. */
  66897. sphere: Mesh;
  66898. }
  66899. /**
  66900. * Interface for gravitational field event data
  66901. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66902. */
  66903. export interface PhysicsGravitationalFieldEventData {
  66904. /**
  66905. * A sphere mesh used for the gravitational field event
  66906. */
  66907. sphere: Mesh;
  66908. }
  66909. /**
  66910. * Interface for updraft event data
  66911. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66912. */
  66913. export interface PhysicsUpdraftEventData {
  66914. /**
  66915. * A cylinder used for the updraft event
  66916. */
  66917. cylinder: Mesh;
  66918. }
  66919. /**
  66920. * Interface for vortex event data
  66921. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66922. */
  66923. export interface PhysicsVortexEventData {
  66924. /**
  66925. * A cylinder used for the vortex event
  66926. */
  66927. cylinder: Mesh;
  66928. }
  66929. /**
  66930. * Interface for an affected physics impostor
  66931. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66932. */
  66933. export interface PhysicsAffectedImpostorWithData {
  66934. /**
  66935. * The impostor affected by the effect
  66936. */
  66937. impostor: PhysicsImpostor;
  66938. /**
  66939. * The data about the hit/horce from the explosion
  66940. */
  66941. hitData: PhysicsHitData;
  66942. }
  66943. }
  66944. declare module BABYLON {
  66945. /** @hidden */
  66946. export var blackAndWhitePixelShader: {
  66947. name: string;
  66948. shader: string;
  66949. };
  66950. }
  66951. declare module BABYLON {
  66952. /**
  66953. * Post process used to render in black and white
  66954. */
  66955. export class BlackAndWhitePostProcess extends PostProcess {
  66956. /**
  66957. * Linear about to convert he result to black and white (default: 1)
  66958. */
  66959. degree: number;
  66960. /**
  66961. * Creates a black and white post process
  66962. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  66963. * @param name The name of the effect.
  66964. * @param options The required width/height ratio to downsize to before computing the render pass.
  66965. * @param camera The camera to apply the render pass to.
  66966. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66967. * @param engine The engine which the post process will be applied. (default: current engine)
  66968. * @param reusable If the post process can be reused on the same frame. (default: false)
  66969. */
  66970. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66971. }
  66972. }
  66973. declare module BABYLON {
  66974. /**
  66975. * This represents a set of one or more post processes in Babylon.
  66976. * A post process can be used to apply a shader to a texture after it is rendered.
  66977. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66978. */
  66979. export class PostProcessRenderEffect {
  66980. private _postProcesses;
  66981. private _getPostProcesses;
  66982. private _singleInstance;
  66983. private _cameras;
  66984. private _indicesForCamera;
  66985. /**
  66986. * Name of the effect
  66987. * @hidden
  66988. */
  66989. _name: string;
  66990. /**
  66991. * Instantiates a post process render effect.
  66992. * A post process can be used to apply a shader to a texture after it is rendered.
  66993. * @param engine The engine the effect is tied to
  66994. * @param name The name of the effect
  66995. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  66996. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  66997. */
  66998. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  66999. /**
  67000. * Checks if all the post processes in the effect are supported.
  67001. */
  67002. get isSupported(): boolean;
  67003. /**
  67004. * Updates the current state of the effect
  67005. * @hidden
  67006. */
  67007. _update(): void;
  67008. /**
  67009. * Attaches the effect on cameras
  67010. * @param cameras The camera to attach to.
  67011. * @hidden
  67012. */
  67013. _attachCameras(cameras: Camera): void;
  67014. /**
  67015. * Attaches the effect on cameras
  67016. * @param cameras The camera to attach to.
  67017. * @hidden
  67018. */
  67019. _attachCameras(cameras: Camera[]): void;
  67020. /**
  67021. * Detaches the effect on cameras
  67022. * @param cameras The camera to detatch from.
  67023. * @hidden
  67024. */
  67025. _detachCameras(cameras: Camera): void;
  67026. /**
  67027. * Detatches the effect on cameras
  67028. * @param cameras The camera to detatch from.
  67029. * @hidden
  67030. */
  67031. _detachCameras(cameras: Camera[]): void;
  67032. /**
  67033. * Enables the effect on given cameras
  67034. * @param cameras The camera to enable.
  67035. * @hidden
  67036. */
  67037. _enable(cameras: Camera): void;
  67038. /**
  67039. * Enables the effect on given cameras
  67040. * @param cameras The camera to enable.
  67041. * @hidden
  67042. */
  67043. _enable(cameras: Nullable<Camera[]>): void;
  67044. /**
  67045. * Disables the effect on the given cameras
  67046. * @param cameras The camera to disable.
  67047. * @hidden
  67048. */
  67049. _disable(cameras: Camera): void;
  67050. /**
  67051. * Disables the effect on the given cameras
  67052. * @param cameras The camera to disable.
  67053. * @hidden
  67054. */
  67055. _disable(cameras: Nullable<Camera[]>): void;
  67056. /**
  67057. * Gets a list of the post processes contained in the effect.
  67058. * @param camera The camera to get the post processes on.
  67059. * @returns The list of the post processes in the effect.
  67060. */
  67061. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  67062. }
  67063. }
  67064. declare module BABYLON {
  67065. /** @hidden */
  67066. export var extractHighlightsPixelShader: {
  67067. name: string;
  67068. shader: string;
  67069. };
  67070. }
  67071. declare module BABYLON {
  67072. /**
  67073. * 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.
  67074. */
  67075. export class ExtractHighlightsPostProcess extends PostProcess {
  67076. /**
  67077. * The luminance threshold, pixels below this value will be set to black.
  67078. */
  67079. threshold: number;
  67080. /** @hidden */
  67081. _exposure: number;
  67082. /**
  67083. * Post process which has the input texture to be used when performing highlight extraction
  67084. * @hidden
  67085. */
  67086. _inputPostProcess: Nullable<PostProcess>;
  67087. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67088. }
  67089. }
  67090. declare module BABYLON {
  67091. /** @hidden */
  67092. export var bloomMergePixelShader: {
  67093. name: string;
  67094. shader: string;
  67095. };
  67096. }
  67097. declare module BABYLON {
  67098. /**
  67099. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67100. */
  67101. export class BloomMergePostProcess extends PostProcess {
  67102. /** Weight of the bloom to be added to the original input. */
  67103. weight: number;
  67104. /**
  67105. * Creates a new instance of @see BloomMergePostProcess
  67106. * @param name The name of the effect.
  67107. * @param originalFromInput Post process which's input will be used for the merge.
  67108. * @param blurred Blurred highlights post process which's output will be used.
  67109. * @param weight Weight of the bloom to be added to the original input.
  67110. * @param options The required width/height ratio to downsize to before computing the render pass.
  67111. * @param camera The camera to apply the render pass to.
  67112. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67113. * @param engine The engine which the post process will be applied. (default: current engine)
  67114. * @param reusable If the post process can be reused on the same frame. (default: false)
  67115. * @param textureType Type of textures used when performing the post process. (default: 0)
  67116. * @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)
  67117. */
  67118. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  67119. /** Weight of the bloom to be added to the original input. */
  67120. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67121. }
  67122. }
  67123. declare module BABYLON {
  67124. /**
  67125. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  67126. */
  67127. export class BloomEffect extends PostProcessRenderEffect {
  67128. private bloomScale;
  67129. /**
  67130. * @hidden Internal
  67131. */
  67132. _effects: Array<PostProcess>;
  67133. /**
  67134. * @hidden Internal
  67135. */
  67136. _downscale: ExtractHighlightsPostProcess;
  67137. private _blurX;
  67138. private _blurY;
  67139. private _merge;
  67140. /**
  67141. * The luminance threshold to find bright areas of the image to bloom.
  67142. */
  67143. get threshold(): number;
  67144. set threshold(value: number);
  67145. /**
  67146. * The strength of the bloom.
  67147. */
  67148. get weight(): number;
  67149. set weight(value: number);
  67150. /**
  67151. * Specifies the size of the bloom blur kernel, relative to the final output size
  67152. */
  67153. get kernel(): number;
  67154. set kernel(value: number);
  67155. /**
  67156. * Creates a new instance of @see BloomEffect
  67157. * @param scene The scene the effect belongs to.
  67158. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  67159. * @param bloomKernel The size of the kernel to be used when applying the blur.
  67160. * @param bloomWeight The the strength of bloom.
  67161. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67162. * @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)
  67163. */
  67164. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  67165. /**
  67166. * Disposes each of the internal effects for a given camera.
  67167. * @param camera The camera to dispose the effect on.
  67168. */
  67169. disposeEffects(camera: Camera): void;
  67170. /**
  67171. * @hidden Internal
  67172. */
  67173. _updateEffects(): void;
  67174. /**
  67175. * Internal
  67176. * @returns if all the contained post processes are ready.
  67177. * @hidden
  67178. */
  67179. _isReady(): boolean;
  67180. }
  67181. }
  67182. declare module BABYLON {
  67183. /** @hidden */
  67184. export var chromaticAberrationPixelShader: {
  67185. name: string;
  67186. shader: string;
  67187. };
  67188. }
  67189. declare module BABYLON {
  67190. /**
  67191. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  67192. */
  67193. export class ChromaticAberrationPostProcess extends PostProcess {
  67194. /**
  67195. * The amount of seperation of rgb channels (default: 30)
  67196. */
  67197. aberrationAmount: number;
  67198. /**
  67199. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  67200. */
  67201. radialIntensity: number;
  67202. /**
  67203. * 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))
  67204. */
  67205. direction: Vector2;
  67206. /**
  67207. * 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))
  67208. */
  67209. centerPosition: Vector2;
  67210. /**
  67211. * Creates a new instance ChromaticAberrationPostProcess
  67212. * @param name The name of the effect.
  67213. * @param screenWidth The width of the screen to apply the effect on.
  67214. * @param screenHeight The height of the screen to apply the effect on.
  67215. * @param options The required width/height ratio to downsize to before computing the render pass.
  67216. * @param camera The camera to apply the render pass to.
  67217. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67218. * @param engine The engine which the post process will be applied. (default: current engine)
  67219. * @param reusable If the post process can be reused on the same frame. (default: false)
  67220. * @param textureType Type of textures used when performing the post process. (default: 0)
  67221. * @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)
  67222. */
  67223. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67224. }
  67225. }
  67226. declare module BABYLON {
  67227. /** @hidden */
  67228. export var circleOfConfusionPixelShader: {
  67229. name: string;
  67230. shader: string;
  67231. };
  67232. }
  67233. declare module BABYLON {
  67234. /**
  67235. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  67236. */
  67237. export class CircleOfConfusionPostProcess extends PostProcess {
  67238. /**
  67239. * 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.
  67240. */
  67241. lensSize: number;
  67242. /**
  67243. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67244. */
  67245. fStop: number;
  67246. /**
  67247. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67248. */
  67249. focusDistance: number;
  67250. /**
  67251. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  67252. */
  67253. focalLength: number;
  67254. private _depthTexture;
  67255. /**
  67256. * Creates a new instance CircleOfConfusionPostProcess
  67257. * @param name The name of the effect.
  67258. * @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.
  67259. * @param options The required width/height ratio to downsize to before computing the render pass.
  67260. * @param camera The camera to apply the render pass to.
  67261. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67262. * @param engine The engine which the post process will be applied. (default: current engine)
  67263. * @param reusable If the post process can be reused on the same frame. (default: false)
  67264. * @param textureType Type of textures used when performing the post process. (default: 0)
  67265. * @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)
  67266. */
  67267. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67268. /**
  67269. * 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.
  67270. */
  67271. set depthTexture(value: RenderTargetTexture);
  67272. }
  67273. }
  67274. declare module BABYLON {
  67275. /** @hidden */
  67276. export var colorCorrectionPixelShader: {
  67277. name: string;
  67278. shader: string;
  67279. };
  67280. }
  67281. declare module BABYLON {
  67282. /**
  67283. *
  67284. * This post-process allows the modification of rendered colors by using
  67285. * a 'look-up table' (LUT). This effect is also called Color Grading.
  67286. *
  67287. * The object needs to be provided an url to a texture containing the color
  67288. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  67289. * Use an image editing software to tweak the LUT to match your needs.
  67290. *
  67291. * For an example of a color LUT, see here:
  67292. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  67293. * For explanations on color grading, see here:
  67294. * @see http://udn.epicgames.com/Three/ColorGrading.html
  67295. *
  67296. */
  67297. export class ColorCorrectionPostProcess extends PostProcess {
  67298. private _colorTableTexture;
  67299. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67300. }
  67301. }
  67302. declare module BABYLON {
  67303. /** @hidden */
  67304. export var convolutionPixelShader: {
  67305. name: string;
  67306. shader: string;
  67307. };
  67308. }
  67309. declare module BABYLON {
  67310. /**
  67311. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  67312. * input texture to perform effects such as edge detection or sharpening
  67313. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67314. */
  67315. export class ConvolutionPostProcess extends PostProcess {
  67316. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67317. kernel: number[];
  67318. /**
  67319. * Creates a new instance ConvolutionPostProcess
  67320. * @param name The name of the effect.
  67321. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  67322. * @param options The required width/height ratio to downsize to before computing the render pass.
  67323. * @param camera The camera to apply the render pass to.
  67324. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67325. * @param engine The engine which the post process will be applied. (default: current engine)
  67326. * @param reusable If the post process can be reused on the same frame. (default: false)
  67327. * @param textureType Type of textures used when performing the post process. (default: 0)
  67328. */
  67329. constructor(name: string,
  67330. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67331. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67332. /**
  67333. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67334. */
  67335. static EdgeDetect0Kernel: number[];
  67336. /**
  67337. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67338. */
  67339. static EdgeDetect1Kernel: number[];
  67340. /**
  67341. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67342. */
  67343. static EdgeDetect2Kernel: number[];
  67344. /**
  67345. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67346. */
  67347. static SharpenKernel: number[];
  67348. /**
  67349. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67350. */
  67351. static EmbossKernel: number[];
  67352. /**
  67353. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67354. */
  67355. static GaussianKernel: number[];
  67356. }
  67357. }
  67358. declare module BABYLON {
  67359. /**
  67360. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  67361. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  67362. * based on samples that have a large difference in distance than the center pixel.
  67363. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  67364. */
  67365. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  67366. direction: Vector2;
  67367. /**
  67368. * Creates a new instance CircleOfConfusionPostProcess
  67369. * @param name The name of the effect.
  67370. * @param scene The scene the effect belongs to.
  67371. * @param direction The direction the blur should be applied.
  67372. * @param kernel The size of the kernel used to blur.
  67373. * @param options The required width/height ratio to downsize to before computing the render pass.
  67374. * @param camera The camera to apply the render pass to.
  67375. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  67376. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  67377. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67378. * @param engine The engine which the post process will be applied. (default: current engine)
  67379. * @param reusable If the post process can be reused on the same frame. (default: false)
  67380. * @param textureType Type of textures used when performing the post process. (default: 0)
  67381. * @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)
  67382. */
  67383. 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);
  67384. }
  67385. }
  67386. declare module BABYLON {
  67387. /** @hidden */
  67388. export var depthOfFieldMergePixelShader: {
  67389. name: string;
  67390. shader: string;
  67391. };
  67392. }
  67393. declare module BABYLON {
  67394. /**
  67395. * Options to be set when merging outputs from the default pipeline.
  67396. */
  67397. export class DepthOfFieldMergePostProcessOptions {
  67398. /**
  67399. * The original image to merge on top of
  67400. */
  67401. originalFromInput: PostProcess;
  67402. /**
  67403. * Parameters to perform the merge of the depth of field effect
  67404. */
  67405. depthOfField?: {
  67406. circleOfConfusion: PostProcess;
  67407. blurSteps: Array<PostProcess>;
  67408. };
  67409. /**
  67410. * Parameters to perform the merge of bloom effect
  67411. */
  67412. bloom?: {
  67413. blurred: PostProcess;
  67414. weight: number;
  67415. };
  67416. }
  67417. /**
  67418. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67419. */
  67420. export class DepthOfFieldMergePostProcess extends PostProcess {
  67421. private blurSteps;
  67422. /**
  67423. * Creates a new instance of DepthOfFieldMergePostProcess
  67424. * @param name The name of the effect.
  67425. * @param originalFromInput Post process which's input will be used for the merge.
  67426. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  67427. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  67428. * @param options The required width/height ratio to downsize to before computing the render pass.
  67429. * @param camera The camera to apply the render pass to.
  67430. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67431. * @param engine The engine which the post process will be applied. (default: current engine)
  67432. * @param reusable If the post process can be reused on the same frame. (default: false)
  67433. * @param textureType Type of textures used when performing the post process. (default: 0)
  67434. * @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)
  67435. */
  67436. 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);
  67437. /**
  67438. * Updates the effect with the current post process compile time values and recompiles the shader.
  67439. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67440. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67441. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67442. * @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
  67443. * @param onCompiled Called when the shader has been compiled.
  67444. * @param onError Called if there is an error when compiling a shader.
  67445. */
  67446. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67447. }
  67448. }
  67449. declare module BABYLON {
  67450. /**
  67451. * Specifies the level of max blur that should be applied when using the depth of field effect
  67452. */
  67453. export enum DepthOfFieldEffectBlurLevel {
  67454. /**
  67455. * Subtle blur
  67456. */
  67457. Low = 0,
  67458. /**
  67459. * Medium blur
  67460. */
  67461. Medium = 1,
  67462. /**
  67463. * Large blur
  67464. */
  67465. High = 2
  67466. }
  67467. /**
  67468. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  67469. */
  67470. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  67471. private _circleOfConfusion;
  67472. /**
  67473. * @hidden Internal, blurs from high to low
  67474. */
  67475. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  67476. private _depthOfFieldBlurY;
  67477. private _dofMerge;
  67478. /**
  67479. * @hidden Internal post processes in depth of field effect
  67480. */
  67481. _effects: Array<PostProcess>;
  67482. /**
  67483. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  67484. */
  67485. set focalLength(value: number);
  67486. get focalLength(): number;
  67487. /**
  67488. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67489. */
  67490. set fStop(value: number);
  67491. get fStop(): number;
  67492. /**
  67493. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67494. */
  67495. set focusDistance(value: number);
  67496. get focusDistance(): number;
  67497. /**
  67498. * 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.
  67499. */
  67500. set lensSize(value: number);
  67501. get lensSize(): number;
  67502. /**
  67503. * Creates a new instance DepthOfFieldEffect
  67504. * @param scene The scene the effect belongs to.
  67505. * @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.
  67506. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67507. * @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)
  67508. */
  67509. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  67510. /**
  67511. * Get the current class name of the current effet
  67512. * @returns "DepthOfFieldEffect"
  67513. */
  67514. getClassName(): string;
  67515. /**
  67516. * 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.
  67517. */
  67518. set depthTexture(value: RenderTargetTexture);
  67519. /**
  67520. * Disposes each of the internal effects for a given camera.
  67521. * @param camera The camera to dispose the effect on.
  67522. */
  67523. disposeEffects(camera: Camera): void;
  67524. /**
  67525. * @hidden Internal
  67526. */
  67527. _updateEffects(): void;
  67528. /**
  67529. * Internal
  67530. * @returns if all the contained post processes are ready.
  67531. * @hidden
  67532. */
  67533. _isReady(): boolean;
  67534. }
  67535. }
  67536. declare module BABYLON {
  67537. /** @hidden */
  67538. export var displayPassPixelShader: {
  67539. name: string;
  67540. shader: string;
  67541. };
  67542. }
  67543. declare module BABYLON {
  67544. /**
  67545. * DisplayPassPostProcess which produces an output the same as it's input
  67546. */
  67547. export class DisplayPassPostProcess extends PostProcess {
  67548. /**
  67549. * Creates the DisplayPassPostProcess
  67550. * @param name The name of the effect.
  67551. * @param options The required width/height ratio to downsize to before computing the render pass.
  67552. * @param camera The camera to apply the render pass to.
  67553. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67554. * @param engine The engine which the post process will be applied. (default: current engine)
  67555. * @param reusable If the post process can be reused on the same frame. (default: false)
  67556. */
  67557. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67558. }
  67559. }
  67560. declare module BABYLON {
  67561. /** @hidden */
  67562. export var filterPixelShader: {
  67563. name: string;
  67564. shader: string;
  67565. };
  67566. }
  67567. declare module BABYLON {
  67568. /**
  67569. * Applies a kernel filter to the image
  67570. */
  67571. export class FilterPostProcess extends PostProcess {
  67572. /** The matrix to be applied to the image */
  67573. kernelMatrix: Matrix;
  67574. /**
  67575. *
  67576. * @param name The name of the effect.
  67577. * @param kernelMatrix The matrix to be applied to the image
  67578. * @param options The required width/height ratio to downsize to before computing the render pass.
  67579. * @param camera The camera to apply the render pass to.
  67580. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67581. * @param engine The engine which the post process will be applied. (default: current engine)
  67582. * @param reusable If the post process can be reused on the same frame. (default: false)
  67583. */
  67584. constructor(name: string,
  67585. /** The matrix to be applied to the image */
  67586. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67587. }
  67588. }
  67589. declare module BABYLON {
  67590. /** @hidden */
  67591. export var fxaaPixelShader: {
  67592. name: string;
  67593. shader: string;
  67594. };
  67595. }
  67596. declare module BABYLON {
  67597. /** @hidden */
  67598. export var fxaaVertexShader: {
  67599. name: string;
  67600. shader: string;
  67601. };
  67602. }
  67603. declare module BABYLON {
  67604. /**
  67605. * Fxaa post process
  67606. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  67607. */
  67608. export class FxaaPostProcess extends PostProcess {
  67609. /** @hidden */
  67610. texelWidth: number;
  67611. /** @hidden */
  67612. texelHeight: number;
  67613. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67614. private _getDefines;
  67615. }
  67616. }
  67617. declare module BABYLON {
  67618. /** @hidden */
  67619. export var grainPixelShader: {
  67620. name: string;
  67621. shader: string;
  67622. };
  67623. }
  67624. declare module BABYLON {
  67625. /**
  67626. * The GrainPostProcess adds noise to the image at mid luminance levels
  67627. */
  67628. export class GrainPostProcess extends PostProcess {
  67629. /**
  67630. * The intensity of the grain added (default: 30)
  67631. */
  67632. intensity: number;
  67633. /**
  67634. * If the grain should be randomized on every frame
  67635. */
  67636. animated: boolean;
  67637. /**
  67638. * Creates a new instance of @see GrainPostProcess
  67639. * @param name The name of the effect.
  67640. * @param options The required width/height ratio to downsize to before computing the render pass.
  67641. * @param camera The camera to apply the render pass to.
  67642. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67643. * @param engine The engine which the post process will be applied. (default: current engine)
  67644. * @param reusable If the post process can be reused on the same frame. (default: false)
  67645. * @param textureType Type of textures used when performing the post process. (default: 0)
  67646. * @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)
  67647. */
  67648. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67649. }
  67650. }
  67651. declare module BABYLON {
  67652. /** @hidden */
  67653. export var highlightsPixelShader: {
  67654. name: string;
  67655. shader: string;
  67656. };
  67657. }
  67658. declare module BABYLON {
  67659. /**
  67660. * Extracts highlights from the image
  67661. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67662. */
  67663. export class HighlightsPostProcess extends PostProcess {
  67664. /**
  67665. * Extracts highlights from the image
  67666. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67667. * @param name The name of the effect.
  67668. * @param options The required width/height ratio to downsize to before computing the render pass.
  67669. * @param camera The camera to apply the render pass to.
  67670. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67671. * @param engine The engine which the post process will be applied. (default: current engine)
  67672. * @param reusable If the post process can be reused on the same frame. (default: false)
  67673. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  67674. */
  67675. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67676. }
  67677. }
  67678. declare module BABYLON {
  67679. /** @hidden */
  67680. export var mrtFragmentDeclaration: {
  67681. name: string;
  67682. shader: string;
  67683. };
  67684. }
  67685. declare module BABYLON {
  67686. /** @hidden */
  67687. export var geometryPixelShader: {
  67688. name: string;
  67689. shader: string;
  67690. };
  67691. }
  67692. declare module BABYLON {
  67693. /** @hidden */
  67694. export var geometryVertexShader: {
  67695. name: string;
  67696. shader: string;
  67697. };
  67698. }
  67699. declare module BABYLON {
  67700. /** @hidden */
  67701. interface ISavedTransformationMatrix {
  67702. world: Matrix;
  67703. viewProjection: Matrix;
  67704. }
  67705. /**
  67706. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  67707. */
  67708. export class GeometryBufferRenderer {
  67709. /**
  67710. * Constant used to retrieve the position texture index in the G-Buffer textures array
  67711. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  67712. */
  67713. static readonly POSITION_TEXTURE_TYPE: number;
  67714. /**
  67715. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  67716. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  67717. */
  67718. static readonly VELOCITY_TEXTURE_TYPE: number;
  67719. /**
  67720. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  67721. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  67722. */
  67723. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  67724. /**
  67725. * Dictionary used to store the previous transformation matrices of each rendered mesh
  67726. * in order to compute objects velocities when enableVelocity is set to "true"
  67727. * @hidden
  67728. */
  67729. _previousTransformationMatrices: {
  67730. [index: number]: ISavedTransformationMatrix;
  67731. };
  67732. /**
  67733. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  67734. * in order to compute objects velocities when enableVelocity is set to "true"
  67735. * @hidden
  67736. */
  67737. _previousBonesTransformationMatrices: {
  67738. [index: number]: Float32Array;
  67739. };
  67740. /**
  67741. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  67742. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  67743. */
  67744. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  67745. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  67746. renderTransparentMeshes: boolean;
  67747. private _scene;
  67748. private _multiRenderTarget;
  67749. private _ratio;
  67750. private _enablePosition;
  67751. private _enableVelocity;
  67752. private _enableReflectivity;
  67753. private _positionIndex;
  67754. private _velocityIndex;
  67755. private _reflectivityIndex;
  67756. protected _effect: Effect;
  67757. protected _cachedDefines: string;
  67758. /**
  67759. * Set the render list (meshes to be rendered) used in the G buffer.
  67760. */
  67761. set renderList(meshes: Mesh[]);
  67762. /**
  67763. * Gets wether or not G buffer are supported by the running hardware.
  67764. * This requires draw buffer supports
  67765. */
  67766. get isSupported(): boolean;
  67767. /**
  67768. * Returns the index of the given texture type in the G-Buffer textures array
  67769. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  67770. * @returns the index of the given texture type in the G-Buffer textures array
  67771. */
  67772. getTextureIndex(textureType: number): number;
  67773. /**
  67774. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  67775. */
  67776. get enablePosition(): boolean;
  67777. /**
  67778. * Sets whether or not objects positions are enabled for the G buffer.
  67779. */
  67780. set enablePosition(enable: boolean);
  67781. /**
  67782. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  67783. */
  67784. get enableVelocity(): boolean;
  67785. /**
  67786. * Sets wether or not objects velocities are enabled for the G buffer.
  67787. */
  67788. set enableVelocity(enable: boolean);
  67789. /**
  67790. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  67791. */
  67792. get enableReflectivity(): boolean;
  67793. /**
  67794. * Sets wether or not objects roughness are enabled for the G buffer.
  67795. */
  67796. set enableReflectivity(enable: boolean);
  67797. /**
  67798. * Gets the scene associated with the buffer.
  67799. */
  67800. get scene(): Scene;
  67801. /**
  67802. * Gets the ratio used by the buffer during its creation.
  67803. * How big is the buffer related to the main canvas.
  67804. */
  67805. get ratio(): number;
  67806. /** @hidden */
  67807. static _SceneComponentInitialization: (scene: Scene) => void;
  67808. /**
  67809. * Creates a new G Buffer for the scene
  67810. * @param scene The scene the buffer belongs to
  67811. * @param ratio How big is the buffer related to the main canvas.
  67812. */
  67813. constructor(scene: Scene, ratio?: number);
  67814. /**
  67815. * Checks wether everything is ready to render a submesh to the G buffer.
  67816. * @param subMesh the submesh to check readiness for
  67817. * @param useInstances is the mesh drawn using instance or not
  67818. * @returns true if ready otherwise false
  67819. */
  67820. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67821. /**
  67822. * Gets the current underlying G Buffer.
  67823. * @returns the buffer
  67824. */
  67825. getGBuffer(): MultiRenderTarget;
  67826. /**
  67827. * Gets the number of samples used to render the buffer (anti aliasing).
  67828. */
  67829. get samples(): number;
  67830. /**
  67831. * Sets the number of samples used to render the buffer (anti aliasing).
  67832. */
  67833. set samples(value: number);
  67834. /**
  67835. * Disposes the renderer and frees up associated resources.
  67836. */
  67837. dispose(): void;
  67838. protected _createRenderTargets(): void;
  67839. private _copyBonesTransformationMatrices;
  67840. }
  67841. }
  67842. declare module BABYLON {
  67843. interface Scene {
  67844. /** @hidden (Backing field) */
  67845. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  67846. /**
  67847. * Gets or Sets the current geometry buffer associated to the scene.
  67848. */
  67849. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  67850. /**
  67851. * Enables a GeometryBufferRender and associates it with the scene
  67852. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  67853. * @returns the GeometryBufferRenderer
  67854. */
  67855. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  67856. /**
  67857. * Disables the GeometryBufferRender associated with the scene
  67858. */
  67859. disableGeometryBufferRenderer(): void;
  67860. }
  67861. /**
  67862. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  67863. * in several rendering techniques.
  67864. */
  67865. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  67866. /**
  67867. * The component name helpful to identify the component in the list of scene components.
  67868. */
  67869. readonly name: string;
  67870. /**
  67871. * The scene the component belongs to.
  67872. */
  67873. scene: Scene;
  67874. /**
  67875. * Creates a new instance of the component for the given scene
  67876. * @param scene Defines the scene to register the component in
  67877. */
  67878. constructor(scene: Scene);
  67879. /**
  67880. * Registers the component in a given scene
  67881. */
  67882. register(): void;
  67883. /**
  67884. * Rebuilds the elements related to this component in case of
  67885. * context lost for instance.
  67886. */
  67887. rebuild(): void;
  67888. /**
  67889. * Disposes the component and the associated ressources
  67890. */
  67891. dispose(): void;
  67892. private _gatherRenderTargets;
  67893. }
  67894. }
  67895. declare module BABYLON {
  67896. /** @hidden */
  67897. export var motionBlurPixelShader: {
  67898. name: string;
  67899. shader: string;
  67900. };
  67901. }
  67902. declare module BABYLON {
  67903. /**
  67904. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  67905. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  67906. * As an example, all you have to do is to create the post-process:
  67907. * var mb = new BABYLON.MotionBlurPostProcess(
  67908. * 'mb', // The name of the effect.
  67909. * scene, // The scene containing the objects to blur according to their velocity.
  67910. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  67911. * camera // The camera to apply the render pass to.
  67912. * );
  67913. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  67914. */
  67915. export class MotionBlurPostProcess extends PostProcess {
  67916. /**
  67917. * Defines how much the image is blurred by the movement. Default value is equal to 1
  67918. */
  67919. motionStrength: number;
  67920. /**
  67921. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  67922. */
  67923. get motionBlurSamples(): number;
  67924. /**
  67925. * Sets the number of iterations to be used for motion blur quality
  67926. */
  67927. set motionBlurSamples(samples: number);
  67928. private _motionBlurSamples;
  67929. private _geometryBufferRenderer;
  67930. /**
  67931. * Creates a new instance MotionBlurPostProcess
  67932. * @param name The name of the effect.
  67933. * @param scene The scene containing the objects to blur according to their velocity.
  67934. * @param options The required width/height ratio to downsize to before computing the render pass.
  67935. * @param camera The camera to apply the render pass to.
  67936. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67937. * @param engine The engine which the post process will be applied. (default: current engine)
  67938. * @param reusable If the post process can be reused on the same frame. (default: false)
  67939. * @param textureType Type of textures used when performing the post process. (default: 0)
  67940. * @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)
  67941. */
  67942. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67943. /**
  67944. * Excludes the given skinned mesh from computing bones velocities.
  67945. * 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.
  67946. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  67947. */
  67948. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  67949. /**
  67950. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  67951. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  67952. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  67953. */
  67954. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  67955. /**
  67956. * Disposes the post process.
  67957. * @param camera The camera to dispose the post process on.
  67958. */
  67959. dispose(camera?: Camera): void;
  67960. }
  67961. }
  67962. declare module BABYLON {
  67963. /** @hidden */
  67964. export var refractionPixelShader: {
  67965. name: string;
  67966. shader: string;
  67967. };
  67968. }
  67969. declare module BABYLON {
  67970. /**
  67971. * Post process which applies a refractin texture
  67972. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  67973. */
  67974. export class RefractionPostProcess extends PostProcess {
  67975. /** the base color of the refraction (used to taint the rendering) */
  67976. color: Color3;
  67977. /** simulated refraction depth */
  67978. depth: number;
  67979. /** the coefficient of the base color (0 to remove base color tainting) */
  67980. colorLevel: number;
  67981. private _refTexture;
  67982. private _ownRefractionTexture;
  67983. /**
  67984. * Gets or sets the refraction texture
  67985. * Please note that you are responsible for disposing the texture if you set it manually
  67986. */
  67987. get refractionTexture(): Texture;
  67988. set refractionTexture(value: Texture);
  67989. /**
  67990. * Initializes the RefractionPostProcess
  67991. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  67992. * @param name The name of the effect.
  67993. * @param refractionTextureUrl Url of the refraction texture to use
  67994. * @param color the base color of the refraction (used to taint the rendering)
  67995. * @param depth simulated refraction depth
  67996. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  67997. * @param camera The camera to apply the render pass to.
  67998. * @param options The required width/height ratio to downsize to before computing the render pass.
  67999. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68000. * @param engine The engine which the post process will be applied. (default: current engine)
  68001. * @param reusable If the post process can be reused on the same frame. (default: false)
  68002. */
  68003. constructor(name: string, refractionTextureUrl: string,
  68004. /** the base color of the refraction (used to taint the rendering) */
  68005. color: Color3,
  68006. /** simulated refraction depth */
  68007. depth: number,
  68008. /** the coefficient of the base color (0 to remove base color tainting) */
  68009. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68010. /**
  68011. * Disposes of the post process
  68012. * @param camera Camera to dispose post process on
  68013. */
  68014. dispose(camera: Camera): void;
  68015. }
  68016. }
  68017. declare module BABYLON {
  68018. /** @hidden */
  68019. export var sharpenPixelShader: {
  68020. name: string;
  68021. shader: string;
  68022. };
  68023. }
  68024. declare module BABYLON {
  68025. /**
  68026. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68027. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68028. */
  68029. export class SharpenPostProcess extends PostProcess {
  68030. /**
  68031. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68032. */
  68033. colorAmount: number;
  68034. /**
  68035. * How much sharpness should be applied (default: 0.3)
  68036. */
  68037. edgeAmount: number;
  68038. /**
  68039. * Creates a new instance ConvolutionPostProcess
  68040. * @param name The name of the effect.
  68041. * @param options The required width/height ratio to downsize to before computing the render pass.
  68042. * @param camera The camera to apply the render pass to.
  68043. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68044. * @param engine The engine which the post process will be applied. (default: current engine)
  68045. * @param reusable If the post process can be reused on the same frame. (default: false)
  68046. * @param textureType Type of textures used when performing the post process. (default: 0)
  68047. * @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)
  68048. */
  68049. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68050. }
  68051. }
  68052. declare module BABYLON {
  68053. /**
  68054. * PostProcessRenderPipeline
  68055. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68056. */
  68057. export class PostProcessRenderPipeline {
  68058. private engine;
  68059. private _renderEffects;
  68060. private _renderEffectsForIsolatedPass;
  68061. /**
  68062. * List of inspectable custom properties (used by the Inspector)
  68063. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68064. */
  68065. inspectableCustomProperties: IInspectable[];
  68066. /**
  68067. * @hidden
  68068. */
  68069. protected _cameras: Camera[];
  68070. /** @hidden */
  68071. _name: string;
  68072. /**
  68073. * Gets pipeline name
  68074. */
  68075. get name(): string;
  68076. /** Gets the list of attached cameras */
  68077. get cameras(): Camera[];
  68078. /**
  68079. * Initializes a PostProcessRenderPipeline
  68080. * @param engine engine to add the pipeline to
  68081. * @param name name of the pipeline
  68082. */
  68083. constructor(engine: Engine, name: string);
  68084. /**
  68085. * Gets the class name
  68086. * @returns "PostProcessRenderPipeline"
  68087. */
  68088. getClassName(): string;
  68089. /**
  68090. * If all the render effects in the pipeline are supported
  68091. */
  68092. get isSupported(): boolean;
  68093. /**
  68094. * Adds an effect to the pipeline
  68095. * @param renderEffect the effect to add
  68096. */
  68097. addEffect(renderEffect: PostProcessRenderEffect): void;
  68098. /** @hidden */
  68099. _rebuild(): void;
  68100. /** @hidden */
  68101. _enableEffect(renderEffectName: string, cameras: Camera): void;
  68102. /** @hidden */
  68103. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  68104. /** @hidden */
  68105. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68106. /** @hidden */
  68107. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68108. /** @hidden */
  68109. _attachCameras(cameras: Camera, unique: boolean): void;
  68110. /** @hidden */
  68111. _attachCameras(cameras: Camera[], unique: boolean): void;
  68112. /** @hidden */
  68113. _detachCameras(cameras: Camera): void;
  68114. /** @hidden */
  68115. _detachCameras(cameras: Nullable<Camera[]>): void;
  68116. /** @hidden */
  68117. _update(): void;
  68118. /** @hidden */
  68119. _reset(): void;
  68120. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  68121. /**
  68122. * Disposes of the pipeline
  68123. */
  68124. dispose(): void;
  68125. }
  68126. }
  68127. declare module BABYLON {
  68128. /**
  68129. * PostProcessRenderPipelineManager class
  68130. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68131. */
  68132. export class PostProcessRenderPipelineManager {
  68133. private _renderPipelines;
  68134. /**
  68135. * Initializes a PostProcessRenderPipelineManager
  68136. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68137. */
  68138. constructor();
  68139. /**
  68140. * Gets the list of supported render pipelines
  68141. */
  68142. get supportedPipelines(): PostProcessRenderPipeline[];
  68143. /**
  68144. * Adds a pipeline to the manager
  68145. * @param renderPipeline The pipeline to add
  68146. */
  68147. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  68148. /**
  68149. * Attaches a camera to the pipeline
  68150. * @param renderPipelineName The name of the pipeline to attach to
  68151. * @param cameras the camera to attach
  68152. * @param unique if the camera can be attached multiple times to the pipeline
  68153. */
  68154. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  68155. /**
  68156. * Detaches a camera from the pipeline
  68157. * @param renderPipelineName The name of the pipeline to detach from
  68158. * @param cameras the camera to detach
  68159. */
  68160. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  68161. /**
  68162. * Enables an effect by name on a pipeline
  68163. * @param renderPipelineName the name of the pipeline to enable the effect in
  68164. * @param renderEffectName the name of the effect to enable
  68165. * @param cameras the cameras that the effect should be enabled on
  68166. */
  68167. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68168. /**
  68169. * Disables an effect by name on a pipeline
  68170. * @param renderPipelineName the name of the pipeline to disable the effect in
  68171. * @param renderEffectName the name of the effect to disable
  68172. * @param cameras the cameras that the effect should be disabled on
  68173. */
  68174. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68175. /**
  68176. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  68177. */
  68178. update(): void;
  68179. /** @hidden */
  68180. _rebuild(): void;
  68181. /**
  68182. * Disposes of the manager and pipelines
  68183. */
  68184. dispose(): void;
  68185. }
  68186. }
  68187. declare module BABYLON {
  68188. interface Scene {
  68189. /** @hidden (Backing field) */
  68190. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68191. /**
  68192. * Gets the postprocess render pipeline manager
  68193. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68194. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68195. */
  68196. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68197. }
  68198. /**
  68199. * Defines the Render Pipeline scene component responsible to rendering pipelines
  68200. */
  68201. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  68202. /**
  68203. * The component name helpfull to identify the component in the list of scene components.
  68204. */
  68205. readonly name: string;
  68206. /**
  68207. * The scene the component belongs to.
  68208. */
  68209. scene: Scene;
  68210. /**
  68211. * Creates a new instance of the component for the given scene
  68212. * @param scene Defines the scene to register the component in
  68213. */
  68214. constructor(scene: Scene);
  68215. /**
  68216. * Registers the component in a given scene
  68217. */
  68218. register(): void;
  68219. /**
  68220. * Rebuilds the elements related to this component in case of
  68221. * context lost for instance.
  68222. */
  68223. rebuild(): void;
  68224. /**
  68225. * Disposes the component and the associated ressources
  68226. */
  68227. dispose(): void;
  68228. private _gatherRenderTargets;
  68229. }
  68230. }
  68231. declare module BABYLON {
  68232. /**
  68233. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  68234. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68235. */
  68236. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68237. private _scene;
  68238. private _camerasToBeAttached;
  68239. /**
  68240. * ID of the sharpen post process,
  68241. */
  68242. private readonly SharpenPostProcessId;
  68243. /**
  68244. * @ignore
  68245. * ID of the image processing post process;
  68246. */
  68247. readonly ImageProcessingPostProcessId: string;
  68248. /**
  68249. * @ignore
  68250. * ID of the Fast Approximate Anti-Aliasing post process;
  68251. */
  68252. readonly FxaaPostProcessId: string;
  68253. /**
  68254. * ID of the chromatic aberration post process,
  68255. */
  68256. private readonly ChromaticAberrationPostProcessId;
  68257. /**
  68258. * ID of the grain post process
  68259. */
  68260. private readonly GrainPostProcessId;
  68261. /**
  68262. * Sharpen post process which will apply a sharpen convolution to enhance edges
  68263. */
  68264. sharpen: SharpenPostProcess;
  68265. private _sharpenEffect;
  68266. private bloom;
  68267. /**
  68268. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  68269. */
  68270. depthOfField: DepthOfFieldEffect;
  68271. /**
  68272. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68273. */
  68274. fxaa: FxaaPostProcess;
  68275. /**
  68276. * Image post processing pass used to perform operations such as tone mapping or color grading.
  68277. */
  68278. imageProcessing: ImageProcessingPostProcess;
  68279. /**
  68280. * Chromatic aberration post process which will shift rgb colors in the image
  68281. */
  68282. chromaticAberration: ChromaticAberrationPostProcess;
  68283. private _chromaticAberrationEffect;
  68284. /**
  68285. * Grain post process which add noise to the image
  68286. */
  68287. grain: GrainPostProcess;
  68288. private _grainEffect;
  68289. /**
  68290. * Glow post process which adds a glow to emissive areas of the image
  68291. */
  68292. private _glowLayer;
  68293. /**
  68294. * Animations which can be used to tweak settings over a period of time
  68295. */
  68296. animations: Animation[];
  68297. private _imageProcessingConfigurationObserver;
  68298. private _sharpenEnabled;
  68299. private _bloomEnabled;
  68300. private _depthOfFieldEnabled;
  68301. private _depthOfFieldBlurLevel;
  68302. private _fxaaEnabled;
  68303. private _imageProcessingEnabled;
  68304. private _defaultPipelineTextureType;
  68305. private _bloomScale;
  68306. private _chromaticAberrationEnabled;
  68307. private _grainEnabled;
  68308. private _buildAllowed;
  68309. /**
  68310. * Gets active scene
  68311. */
  68312. get scene(): Scene;
  68313. /**
  68314. * Enable or disable the sharpen process from the pipeline
  68315. */
  68316. set sharpenEnabled(enabled: boolean);
  68317. get sharpenEnabled(): boolean;
  68318. private _resizeObserver;
  68319. private _hardwareScaleLevel;
  68320. private _bloomKernel;
  68321. /**
  68322. * Specifies the size of the bloom blur kernel, relative to the final output size
  68323. */
  68324. get bloomKernel(): number;
  68325. set bloomKernel(value: number);
  68326. /**
  68327. * Specifies the weight of the bloom in the final rendering
  68328. */
  68329. private _bloomWeight;
  68330. /**
  68331. * Specifies the luma threshold for the area that will be blurred by the bloom
  68332. */
  68333. private _bloomThreshold;
  68334. private _hdr;
  68335. /**
  68336. * The strength of the bloom.
  68337. */
  68338. set bloomWeight(value: number);
  68339. get bloomWeight(): number;
  68340. /**
  68341. * The strength of the bloom.
  68342. */
  68343. set bloomThreshold(value: number);
  68344. get bloomThreshold(): number;
  68345. /**
  68346. * The scale of the bloom, lower value will provide better performance.
  68347. */
  68348. set bloomScale(value: number);
  68349. get bloomScale(): number;
  68350. /**
  68351. * Enable or disable the bloom from the pipeline
  68352. */
  68353. set bloomEnabled(enabled: boolean);
  68354. get bloomEnabled(): boolean;
  68355. private _rebuildBloom;
  68356. /**
  68357. * If the depth of field is enabled.
  68358. */
  68359. get depthOfFieldEnabled(): boolean;
  68360. set depthOfFieldEnabled(enabled: boolean);
  68361. /**
  68362. * Blur level of the depth of field effect. (Higher blur will effect performance)
  68363. */
  68364. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  68365. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  68366. /**
  68367. * If the anti aliasing is enabled.
  68368. */
  68369. set fxaaEnabled(enabled: boolean);
  68370. get fxaaEnabled(): boolean;
  68371. private _samples;
  68372. /**
  68373. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  68374. */
  68375. set samples(sampleCount: number);
  68376. get samples(): number;
  68377. /**
  68378. * If image processing is enabled.
  68379. */
  68380. set imageProcessingEnabled(enabled: boolean);
  68381. get imageProcessingEnabled(): boolean;
  68382. /**
  68383. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  68384. */
  68385. set glowLayerEnabled(enabled: boolean);
  68386. get glowLayerEnabled(): boolean;
  68387. /**
  68388. * Gets the glow layer (or null if not defined)
  68389. */
  68390. get glowLayer(): Nullable<GlowLayer>;
  68391. /**
  68392. * Enable or disable the chromaticAberration process from the pipeline
  68393. */
  68394. set chromaticAberrationEnabled(enabled: boolean);
  68395. get chromaticAberrationEnabled(): boolean;
  68396. /**
  68397. * Enable or disable the grain process from the pipeline
  68398. */
  68399. set grainEnabled(enabled: boolean);
  68400. get grainEnabled(): boolean;
  68401. /**
  68402. * @constructor
  68403. * @param name - The rendering pipeline name (default: "")
  68404. * @param hdr - If high dynamic range textures should be used (default: true)
  68405. * @param scene - The scene linked to this pipeline (default: the last created scene)
  68406. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  68407. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  68408. */
  68409. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  68410. /**
  68411. * Get the class name
  68412. * @returns "DefaultRenderingPipeline"
  68413. */
  68414. getClassName(): string;
  68415. /**
  68416. * Force the compilation of the entire pipeline.
  68417. */
  68418. prepare(): void;
  68419. private _hasCleared;
  68420. private _prevPostProcess;
  68421. private _prevPrevPostProcess;
  68422. private _setAutoClearAndTextureSharing;
  68423. private _depthOfFieldSceneObserver;
  68424. private _buildPipeline;
  68425. private _disposePostProcesses;
  68426. /**
  68427. * Adds a camera to the pipeline
  68428. * @param camera the camera to be added
  68429. */
  68430. addCamera(camera: Camera): void;
  68431. /**
  68432. * Removes a camera from the pipeline
  68433. * @param camera the camera to remove
  68434. */
  68435. removeCamera(camera: Camera): void;
  68436. /**
  68437. * Dispose of the pipeline and stop all post processes
  68438. */
  68439. dispose(): void;
  68440. /**
  68441. * Serialize the rendering pipeline (Used when exporting)
  68442. * @returns the serialized object
  68443. */
  68444. serialize(): any;
  68445. /**
  68446. * Parse the serialized pipeline
  68447. * @param source Source pipeline.
  68448. * @param scene The scene to load the pipeline to.
  68449. * @param rootUrl The URL of the serialized pipeline.
  68450. * @returns An instantiated pipeline from the serialized object.
  68451. */
  68452. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  68453. }
  68454. }
  68455. declare module BABYLON {
  68456. /** @hidden */
  68457. export var lensHighlightsPixelShader: {
  68458. name: string;
  68459. shader: string;
  68460. };
  68461. }
  68462. declare module BABYLON {
  68463. /** @hidden */
  68464. export var depthOfFieldPixelShader: {
  68465. name: string;
  68466. shader: string;
  68467. };
  68468. }
  68469. declare module BABYLON {
  68470. /**
  68471. * BABYLON.JS Chromatic Aberration GLSL Shader
  68472. * Author: Olivier Guyot
  68473. * Separates very slightly R, G and B colors on the edges of the screen
  68474. * Inspired by Francois Tarlier & Martins Upitis
  68475. */
  68476. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  68477. /**
  68478. * @ignore
  68479. * The chromatic aberration PostProcess id in the pipeline
  68480. */
  68481. LensChromaticAberrationEffect: string;
  68482. /**
  68483. * @ignore
  68484. * The highlights enhancing PostProcess id in the pipeline
  68485. */
  68486. HighlightsEnhancingEffect: string;
  68487. /**
  68488. * @ignore
  68489. * The depth-of-field PostProcess id in the pipeline
  68490. */
  68491. LensDepthOfFieldEffect: string;
  68492. private _scene;
  68493. private _depthTexture;
  68494. private _grainTexture;
  68495. private _chromaticAberrationPostProcess;
  68496. private _highlightsPostProcess;
  68497. private _depthOfFieldPostProcess;
  68498. private _edgeBlur;
  68499. private _grainAmount;
  68500. private _chromaticAberration;
  68501. private _distortion;
  68502. private _highlightsGain;
  68503. private _highlightsThreshold;
  68504. private _dofDistance;
  68505. private _dofAperture;
  68506. private _dofDarken;
  68507. private _dofPentagon;
  68508. private _blurNoise;
  68509. /**
  68510. * @constructor
  68511. *
  68512. * Effect parameters are as follow:
  68513. * {
  68514. * chromatic_aberration: number; // from 0 to x (1 for realism)
  68515. * edge_blur: number; // from 0 to x (1 for realism)
  68516. * distortion: number; // from 0 to x (1 for realism)
  68517. * grain_amount: number; // from 0 to 1
  68518. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  68519. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  68520. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  68521. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  68522. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  68523. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  68524. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  68525. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  68526. * }
  68527. * Note: if an effect parameter is unset, effect is disabled
  68528. *
  68529. * @param name The rendering pipeline name
  68530. * @param parameters - An object containing all parameters (see above)
  68531. * @param scene The scene linked to this pipeline
  68532. * @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)
  68533. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68534. */
  68535. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  68536. /**
  68537. * Get the class name
  68538. * @returns "LensRenderingPipeline"
  68539. */
  68540. getClassName(): string;
  68541. /**
  68542. * Gets associated scene
  68543. */
  68544. get scene(): Scene;
  68545. /**
  68546. * Gets or sets the edge blur
  68547. */
  68548. get edgeBlur(): number;
  68549. set edgeBlur(value: number);
  68550. /**
  68551. * Gets or sets the grain amount
  68552. */
  68553. get grainAmount(): number;
  68554. set grainAmount(value: number);
  68555. /**
  68556. * Gets or sets the chromatic aberration amount
  68557. */
  68558. get chromaticAberration(): number;
  68559. set chromaticAberration(value: number);
  68560. /**
  68561. * Gets or sets the depth of field aperture
  68562. */
  68563. get dofAperture(): number;
  68564. set dofAperture(value: number);
  68565. /**
  68566. * Gets or sets the edge distortion
  68567. */
  68568. get edgeDistortion(): number;
  68569. set edgeDistortion(value: number);
  68570. /**
  68571. * Gets or sets the depth of field distortion
  68572. */
  68573. get dofDistortion(): number;
  68574. set dofDistortion(value: number);
  68575. /**
  68576. * Gets or sets the darken out of focus amount
  68577. */
  68578. get darkenOutOfFocus(): number;
  68579. set darkenOutOfFocus(value: number);
  68580. /**
  68581. * Gets or sets a boolean indicating if blur noise is enabled
  68582. */
  68583. get blurNoise(): boolean;
  68584. set blurNoise(value: boolean);
  68585. /**
  68586. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  68587. */
  68588. get pentagonBokeh(): boolean;
  68589. set pentagonBokeh(value: boolean);
  68590. /**
  68591. * Gets or sets the highlight grain amount
  68592. */
  68593. get highlightsGain(): number;
  68594. set highlightsGain(value: number);
  68595. /**
  68596. * Gets or sets the highlight threshold
  68597. */
  68598. get highlightsThreshold(): number;
  68599. set highlightsThreshold(value: number);
  68600. /**
  68601. * Sets the amount of blur at the edges
  68602. * @param amount blur amount
  68603. */
  68604. setEdgeBlur(amount: number): void;
  68605. /**
  68606. * Sets edge blur to 0
  68607. */
  68608. disableEdgeBlur(): void;
  68609. /**
  68610. * Sets the amout of grain
  68611. * @param amount Amount of grain
  68612. */
  68613. setGrainAmount(amount: number): void;
  68614. /**
  68615. * Set grain amount to 0
  68616. */
  68617. disableGrain(): void;
  68618. /**
  68619. * Sets the chromatic aberration amount
  68620. * @param amount amount of chromatic aberration
  68621. */
  68622. setChromaticAberration(amount: number): void;
  68623. /**
  68624. * Sets chromatic aberration amount to 0
  68625. */
  68626. disableChromaticAberration(): void;
  68627. /**
  68628. * Sets the EdgeDistortion amount
  68629. * @param amount amount of EdgeDistortion
  68630. */
  68631. setEdgeDistortion(amount: number): void;
  68632. /**
  68633. * Sets edge distortion to 0
  68634. */
  68635. disableEdgeDistortion(): void;
  68636. /**
  68637. * Sets the FocusDistance amount
  68638. * @param amount amount of FocusDistance
  68639. */
  68640. setFocusDistance(amount: number): void;
  68641. /**
  68642. * Disables depth of field
  68643. */
  68644. disableDepthOfField(): void;
  68645. /**
  68646. * Sets the Aperture amount
  68647. * @param amount amount of Aperture
  68648. */
  68649. setAperture(amount: number): void;
  68650. /**
  68651. * Sets the DarkenOutOfFocus amount
  68652. * @param amount amount of DarkenOutOfFocus
  68653. */
  68654. setDarkenOutOfFocus(amount: number): void;
  68655. private _pentagonBokehIsEnabled;
  68656. /**
  68657. * Creates a pentagon bokeh effect
  68658. */
  68659. enablePentagonBokeh(): void;
  68660. /**
  68661. * Disables the pentagon bokeh effect
  68662. */
  68663. disablePentagonBokeh(): void;
  68664. /**
  68665. * Enables noise blur
  68666. */
  68667. enableNoiseBlur(): void;
  68668. /**
  68669. * Disables noise blur
  68670. */
  68671. disableNoiseBlur(): void;
  68672. /**
  68673. * Sets the HighlightsGain amount
  68674. * @param amount amount of HighlightsGain
  68675. */
  68676. setHighlightsGain(amount: number): void;
  68677. /**
  68678. * Sets the HighlightsThreshold amount
  68679. * @param amount amount of HighlightsThreshold
  68680. */
  68681. setHighlightsThreshold(amount: number): void;
  68682. /**
  68683. * Disables highlights
  68684. */
  68685. disableHighlights(): void;
  68686. /**
  68687. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  68688. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  68689. */
  68690. dispose(disableDepthRender?: boolean): void;
  68691. private _createChromaticAberrationPostProcess;
  68692. private _createHighlightsPostProcess;
  68693. private _createDepthOfFieldPostProcess;
  68694. private _createGrainTexture;
  68695. }
  68696. }
  68697. declare module BABYLON {
  68698. /** @hidden */
  68699. export var ssao2PixelShader: {
  68700. name: string;
  68701. shader: string;
  68702. };
  68703. }
  68704. declare module BABYLON {
  68705. /** @hidden */
  68706. export var ssaoCombinePixelShader: {
  68707. name: string;
  68708. shader: string;
  68709. };
  68710. }
  68711. declare module BABYLON {
  68712. /**
  68713. * Render pipeline to produce ssao effect
  68714. */
  68715. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  68716. /**
  68717. * @ignore
  68718. * The PassPostProcess id in the pipeline that contains the original scene color
  68719. */
  68720. SSAOOriginalSceneColorEffect: string;
  68721. /**
  68722. * @ignore
  68723. * The SSAO PostProcess id in the pipeline
  68724. */
  68725. SSAORenderEffect: string;
  68726. /**
  68727. * @ignore
  68728. * The horizontal blur PostProcess id in the pipeline
  68729. */
  68730. SSAOBlurHRenderEffect: string;
  68731. /**
  68732. * @ignore
  68733. * The vertical blur PostProcess id in the pipeline
  68734. */
  68735. SSAOBlurVRenderEffect: string;
  68736. /**
  68737. * @ignore
  68738. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  68739. */
  68740. SSAOCombineRenderEffect: string;
  68741. /**
  68742. * The output strength of the SSAO post-process. Default value is 1.0.
  68743. */
  68744. totalStrength: number;
  68745. /**
  68746. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  68747. */
  68748. maxZ: number;
  68749. /**
  68750. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  68751. */
  68752. minZAspect: number;
  68753. private _samples;
  68754. /**
  68755. * Number of samples used for the SSAO calculations. Default value is 8
  68756. */
  68757. set samples(n: number);
  68758. get samples(): number;
  68759. private _textureSamples;
  68760. /**
  68761. * Number of samples to use for antialiasing
  68762. */
  68763. set textureSamples(n: number);
  68764. get textureSamples(): number;
  68765. /**
  68766. * Ratio object used for SSAO ratio and blur ratio
  68767. */
  68768. private _ratio;
  68769. /**
  68770. * Dynamically generated sphere sampler.
  68771. */
  68772. private _sampleSphere;
  68773. /**
  68774. * Blur filter offsets
  68775. */
  68776. private _samplerOffsets;
  68777. private _expensiveBlur;
  68778. /**
  68779. * If bilateral blur should be used
  68780. */
  68781. set expensiveBlur(b: boolean);
  68782. get expensiveBlur(): boolean;
  68783. /**
  68784. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  68785. */
  68786. radius: number;
  68787. /**
  68788. * The base color of the SSAO post-process
  68789. * The final result is "base + ssao" between [0, 1]
  68790. */
  68791. base: number;
  68792. /**
  68793. * Support test.
  68794. */
  68795. static get IsSupported(): boolean;
  68796. private _scene;
  68797. private _depthTexture;
  68798. private _normalTexture;
  68799. private _randomTexture;
  68800. private _originalColorPostProcess;
  68801. private _ssaoPostProcess;
  68802. private _blurHPostProcess;
  68803. private _blurVPostProcess;
  68804. private _ssaoCombinePostProcess;
  68805. /**
  68806. * Gets active scene
  68807. */
  68808. get scene(): Scene;
  68809. /**
  68810. * @constructor
  68811. * @param name The rendering pipeline name
  68812. * @param scene The scene linked to this pipeline
  68813. * @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 }
  68814. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68815. */
  68816. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  68817. /**
  68818. * Get the class name
  68819. * @returns "SSAO2RenderingPipeline"
  68820. */
  68821. getClassName(): string;
  68822. /**
  68823. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  68824. */
  68825. dispose(disableGeometryBufferRenderer?: boolean): void;
  68826. private _createBlurPostProcess;
  68827. /** @hidden */
  68828. _rebuild(): void;
  68829. private _bits;
  68830. private _radicalInverse_VdC;
  68831. private _hammersley;
  68832. private _hemisphereSample_uniform;
  68833. private _generateHemisphere;
  68834. private _createSSAOPostProcess;
  68835. private _createSSAOCombinePostProcess;
  68836. private _createRandomTexture;
  68837. /**
  68838. * Serialize the rendering pipeline (Used when exporting)
  68839. * @returns the serialized object
  68840. */
  68841. serialize(): any;
  68842. /**
  68843. * Parse the serialized pipeline
  68844. * @param source Source pipeline.
  68845. * @param scene The scene to load the pipeline to.
  68846. * @param rootUrl The URL of the serialized pipeline.
  68847. * @returns An instantiated pipeline from the serialized object.
  68848. */
  68849. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  68850. }
  68851. }
  68852. declare module BABYLON {
  68853. /** @hidden */
  68854. export var ssaoPixelShader: {
  68855. name: string;
  68856. shader: string;
  68857. };
  68858. }
  68859. declare module BABYLON {
  68860. /**
  68861. * Render pipeline to produce ssao effect
  68862. */
  68863. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  68864. /**
  68865. * @ignore
  68866. * The PassPostProcess id in the pipeline that contains the original scene color
  68867. */
  68868. SSAOOriginalSceneColorEffect: string;
  68869. /**
  68870. * @ignore
  68871. * The SSAO PostProcess id in the pipeline
  68872. */
  68873. SSAORenderEffect: string;
  68874. /**
  68875. * @ignore
  68876. * The horizontal blur PostProcess id in the pipeline
  68877. */
  68878. SSAOBlurHRenderEffect: string;
  68879. /**
  68880. * @ignore
  68881. * The vertical blur PostProcess id in the pipeline
  68882. */
  68883. SSAOBlurVRenderEffect: string;
  68884. /**
  68885. * @ignore
  68886. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  68887. */
  68888. SSAOCombineRenderEffect: string;
  68889. /**
  68890. * The output strength of the SSAO post-process. Default value is 1.0.
  68891. */
  68892. totalStrength: number;
  68893. /**
  68894. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  68895. */
  68896. radius: number;
  68897. /**
  68898. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  68899. * Must not be equal to fallOff and superior to fallOff.
  68900. * Default value is 0.0075
  68901. */
  68902. area: number;
  68903. /**
  68904. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  68905. * Must not be equal to area and inferior to area.
  68906. * Default value is 0.000001
  68907. */
  68908. fallOff: number;
  68909. /**
  68910. * The base color of the SSAO post-process
  68911. * The final result is "base + ssao" between [0, 1]
  68912. */
  68913. base: number;
  68914. private _scene;
  68915. private _depthTexture;
  68916. private _randomTexture;
  68917. private _originalColorPostProcess;
  68918. private _ssaoPostProcess;
  68919. private _blurHPostProcess;
  68920. private _blurVPostProcess;
  68921. private _ssaoCombinePostProcess;
  68922. private _firstUpdate;
  68923. /**
  68924. * Gets active scene
  68925. */
  68926. get scene(): Scene;
  68927. /**
  68928. * @constructor
  68929. * @param name - The rendering pipeline name
  68930. * @param scene - The scene linked to this pipeline
  68931. * @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 }
  68932. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  68933. */
  68934. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  68935. /**
  68936. * Get the class name
  68937. * @returns "SSAORenderingPipeline"
  68938. */
  68939. getClassName(): string;
  68940. /**
  68941. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  68942. */
  68943. dispose(disableDepthRender?: boolean): void;
  68944. private _createBlurPostProcess;
  68945. /** @hidden */
  68946. _rebuild(): void;
  68947. private _createSSAOPostProcess;
  68948. private _createSSAOCombinePostProcess;
  68949. private _createRandomTexture;
  68950. }
  68951. }
  68952. declare module BABYLON {
  68953. /** @hidden */
  68954. export var screenSpaceReflectionPixelShader: {
  68955. name: string;
  68956. shader: string;
  68957. };
  68958. }
  68959. declare module BABYLON {
  68960. /**
  68961. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  68962. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  68963. */
  68964. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  68965. /**
  68966. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  68967. */
  68968. threshold: number;
  68969. /**
  68970. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  68971. */
  68972. strength: number;
  68973. /**
  68974. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  68975. */
  68976. reflectionSpecularFalloffExponent: number;
  68977. /**
  68978. * 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]
  68979. */
  68980. step: number;
  68981. /**
  68982. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  68983. */
  68984. roughnessFactor: number;
  68985. private _geometryBufferRenderer;
  68986. private _enableSmoothReflections;
  68987. private _reflectionSamples;
  68988. private _smoothSteps;
  68989. /**
  68990. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  68991. * @param name The name of the effect.
  68992. * @param scene The scene containing the objects to calculate reflections.
  68993. * @param options The required width/height ratio to downsize to before computing the render pass.
  68994. * @param camera The camera to apply the render pass to.
  68995. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68996. * @param engine The engine which the post process will be applied. (default: current engine)
  68997. * @param reusable If the post process can be reused on the same frame. (default: false)
  68998. * @param textureType Type of textures used when performing the post process. (default: 0)
  68999. * @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)
  69000. */
  69001. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69002. /**
  69003. * Gets wether or not smoothing reflections is enabled.
  69004. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69005. */
  69006. get enableSmoothReflections(): boolean;
  69007. /**
  69008. * Sets wether or not smoothing reflections is enabled.
  69009. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69010. */
  69011. set enableSmoothReflections(enabled: boolean);
  69012. /**
  69013. * Gets the number of samples taken while computing reflections. More samples count is high,
  69014. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69015. */
  69016. get reflectionSamples(): number;
  69017. /**
  69018. * Sets the number of samples taken while computing reflections. More samples count is high,
  69019. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69020. */
  69021. set reflectionSamples(samples: number);
  69022. /**
  69023. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  69024. * more the post-process will require GPU power and can generate a drop in FPS.
  69025. * Default value (5.0) work pretty well in all cases but can be adjusted.
  69026. */
  69027. get smoothSteps(): number;
  69028. set smoothSteps(steps: number);
  69029. private _updateEffectDefines;
  69030. }
  69031. }
  69032. declare module BABYLON {
  69033. /** @hidden */
  69034. export var standardPixelShader: {
  69035. name: string;
  69036. shader: string;
  69037. };
  69038. }
  69039. declare module BABYLON {
  69040. /**
  69041. * Standard rendering pipeline
  69042. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69043. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69044. */
  69045. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69046. /**
  69047. * Public members
  69048. */
  69049. /**
  69050. * Post-process which contains the original scene color before the pipeline applies all the effects
  69051. */
  69052. originalPostProcess: Nullable<PostProcess>;
  69053. /**
  69054. * Post-process used to down scale an image x4
  69055. */
  69056. downSampleX4PostProcess: Nullable<PostProcess>;
  69057. /**
  69058. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69059. */
  69060. brightPassPostProcess: Nullable<PostProcess>;
  69061. /**
  69062. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69063. */
  69064. blurHPostProcesses: PostProcess[];
  69065. /**
  69066. * Post-process array storing all the vertical blur post-processes used by the pipeline
  69067. */
  69068. blurVPostProcesses: PostProcess[];
  69069. /**
  69070. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  69071. */
  69072. textureAdderPostProcess: Nullable<PostProcess>;
  69073. /**
  69074. * Post-process used to create volumetric lighting effect
  69075. */
  69076. volumetricLightPostProcess: Nullable<PostProcess>;
  69077. /**
  69078. * Post-process used to smooth the previous volumetric light post-process on the X axis
  69079. */
  69080. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  69081. /**
  69082. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  69083. */
  69084. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  69085. /**
  69086. * Post-process used to merge the volumetric light effect and the real scene color
  69087. */
  69088. volumetricLightMergePostProces: Nullable<PostProcess>;
  69089. /**
  69090. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  69091. */
  69092. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  69093. /**
  69094. * Base post-process used to calculate the average luminance of the final image for HDR
  69095. */
  69096. luminancePostProcess: Nullable<PostProcess>;
  69097. /**
  69098. * Post-processes used to create down sample post-processes in order to get
  69099. * the average luminance of the final image for HDR
  69100. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  69101. */
  69102. luminanceDownSamplePostProcesses: PostProcess[];
  69103. /**
  69104. * Post-process used to create a HDR effect (light adaptation)
  69105. */
  69106. hdrPostProcess: Nullable<PostProcess>;
  69107. /**
  69108. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  69109. */
  69110. textureAdderFinalPostProcess: Nullable<PostProcess>;
  69111. /**
  69112. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  69113. */
  69114. lensFlareFinalPostProcess: Nullable<PostProcess>;
  69115. /**
  69116. * Post-process used to merge the final HDR post-process and the real scene color
  69117. */
  69118. hdrFinalPostProcess: Nullable<PostProcess>;
  69119. /**
  69120. * Post-process used to create a lens flare effect
  69121. */
  69122. lensFlarePostProcess: Nullable<PostProcess>;
  69123. /**
  69124. * Post-process that merges the result of the lens flare post-process and the real scene color
  69125. */
  69126. lensFlareComposePostProcess: Nullable<PostProcess>;
  69127. /**
  69128. * Post-process used to create a motion blur effect
  69129. */
  69130. motionBlurPostProcess: Nullable<PostProcess>;
  69131. /**
  69132. * Post-process used to create a depth of field effect
  69133. */
  69134. depthOfFieldPostProcess: Nullable<PostProcess>;
  69135. /**
  69136. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69137. */
  69138. fxaaPostProcess: Nullable<FxaaPostProcess>;
  69139. /**
  69140. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  69141. */
  69142. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  69143. /**
  69144. * Represents the brightness threshold in order to configure the illuminated surfaces
  69145. */
  69146. brightThreshold: number;
  69147. /**
  69148. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  69149. */
  69150. blurWidth: number;
  69151. /**
  69152. * Sets if the blur for highlighted surfaces must be only horizontal
  69153. */
  69154. horizontalBlur: boolean;
  69155. /**
  69156. * Gets the overall exposure used by the pipeline
  69157. */
  69158. get exposure(): number;
  69159. /**
  69160. * Sets the overall exposure used by the pipeline
  69161. */
  69162. set exposure(value: number);
  69163. /**
  69164. * Texture used typically to simulate "dirty" on camera lens
  69165. */
  69166. lensTexture: Nullable<Texture>;
  69167. /**
  69168. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  69169. */
  69170. volumetricLightCoefficient: number;
  69171. /**
  69172. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  69173. */
  69174. volumetricLightPower: number;
  69175. /**
  69176. * Used the set the blur intensity to smooth the volumetric lights
  69177. */
  69178. volumetricLightBlurScale: number;
  69179. /**
  69180. * Light (spot or directional) used to generate the volumetric lights rays
  69181. * The source light must have a shadow generate so the pipeline can get its
  69182. * depth map
  69183. */
  69184. sourceLight: Nullable<SpotLight | DirectionalLight>;
  69185. /**
  69186. * For eye adaptation, represents the minimum luminance the eye can see
  69187. */
  69188. hdrMinimumLuminance: number;
  69189. /**
  69190. * For eye adaptation, represents the decrease luminance speed
  69191. */
  69192. hdrDecreaseRate: number;
  69193. /**
  69194. * For eye adaptation, represents the increase luminance speed
  69195. */
  69196. hdrIncreaseRate: number;
  69197. /**
  69198. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69199. */
  69200. get hdrAutoExposure(): boolean;
  69201. /**
  69202. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69203. */
  69204. set hdrAutoExposure(value: boolean);
  69205. /**
  69206. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  69207. */
  69208. lensColorTexture: Nullable<Texture>;
  69209. /**
  69210. * The overall strengh for the lens flare effect
  69211. */
  69212. lensFlareStrength: number;
  69213. /**
  69214. * Dispersion coefficient for lens flare ghosts
  69215. */
  69216. lensFlareGhostDispersal: number;
  69217. /**
  69218. * Main lens flare halo width
  69219. */
  69220. lensFlareHaloWidth: number;
  69221. /**
  69222. * Based on the lens distortion effect, defines how much the lens flare result
  69223. * is distorted
  69224. */
  69225. lensFlareDistortionStrength: number;
  69226. /**
  69227. * Configures the blur intensity used for for lens flare (halo)
  69228. */
  69229. lensFlareBlurWidth: number;
  69230. /**
  69231. * Lens star texture must be used to simulate rays on the flares and is available
  69232. * in the documentation
  69233. */
  69234. lensStarTexture: Nullable<Texture>;
  69235. /**
  69236. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  69237. * flare effect by taking account of the dirt texture
  69238. */
  69239. lensFlareDirtTexture: Nullable<Texture>;
  69240. /**
  69241. * Represents the focal length for the depth of field effect
  69242. */
  69243. depthOfFieldDistance: number;
  69244. /**
  69245. * Represents the blur intensity for the blurred part of the depth of field effect
  69246. */
  69247. depthOfFieldBlurWidth: number;
  69248. /**
  69249. * Gets how much the image is blurred by the movement while using the motion blur post-process
  69250. */
  69251. get motionStrength(): number;
  69252. /**
  69253. * Sets how much the image is blurred by the movement while using the motion blur post-process
  69254. */
  69255. set motionStrength(strength: number);
  69256. /**
  69257. * Gets wether or not the motion blur post-process is object based or screen based.
  69258. */
  69259. get objectBasedMotionBlur(): boolean;
  69260. /**
  69261. * Sets wether or not the motion blur post-process should be object based or screen based
  69262. */
  69263. set objectBasedMotionBlur(value: boolean);
  69264. /**
  69265. * List of animations for the pipeline (IAnimatable implementation)
  69266. */
  69267. animations: Animation[];
  69268. /**
  69269. * Private members
  69270. */
  69271. private _scene;
  69272. private _currentDepthOfFieldSource;
  69273. private _basePostProcess;
  69274. private _fixedExposure;
  69275. private _currentExposure;
  69276. private _hdrAutoExposure;
  69277. private _hdrCurrentLuminance;
  69278. private _motionStrength;
  69279. private _isObjectBasedMotionBlur;
  69280. private _floatTextureType;
  69281. private _camerasToBeAttached;
  69282. private _ratio;
  69283. private _bloomEnabled;
  69284. private _depthOfFieldEnabled;
  69285. private _vlsEnabled;
  69286. private _lensFlareEnabled;
  69287. private _hdrEnabled;
  69288. private _motionBlurEnabled;
  69289. private _fxaaEnabled;
  69290. private _screenSpaceReflectionsEnabled;
  69291. private _motionBlurSamples;
  69292. private _volumetricLightStepsCount;
  69293. private _samples;
  69294. /**
  69295. * @ignore
  69296. * Specifies if the bloom pipeline is enabled
  69297. */
  69298. get BloomEnabled(): boolean;
  69299. set BloomEnabled(enabled: boolean);
  69300. /**
  69301. * @ignore
  69302. * Specifies if the depth of field pipeline is enabed
  69303. */
  69304. get DepthOfFieldEnabled(): boolean;
  69305. set DepthOfFieldEnabled(enabled: boolean);
  69306. /**
  69307. * @ignore
  69308. * Specifies if the lens flare pipeline is enabed
  69309. */
  69310. get LensFlareEnabled(): boolean;
  69311. set LensFlareEnabled(enabled: boolean);
  69312. /**
  69313. * @ignore
  69314. * Specifies if the HDR pipeline is enabled
  69315. */
  69316. get HDREnabled(): boolean;
  69317. set HDREnabled(enabled: boolean);
  69318. /**
  69319. * @ignore
  69320. * Specifies if the volumetric lights scattering effect is enabled
  69321. */
  69322. get VLSEnabled(): boolean;
  69323. set VLSEnabled(enabled: boolean);
  69324. /**
  69325. * @ignore
  69326. * Specifies if the motion blur effect is enabled
  69327. */
  69328. get MotionBlurEnabled(): boolean;
  69329. set MotionBlurEnabled(enabled: boolean);
  69330. /**
  69331. * Specifies if anti-aliasing is enabled
  69332. */
  69333. get fxaaEnabled(): boolean;
  69334. set fxaaEnabled(enabled: boolean);
  69335. /**
  69336. * Specifies if screen space reflections are enabled.
  69337. */
  69338. get screenSpaceReflectionsEnabled(): boolean;
  69339. set screenSpaceReflectionsEnabled(enabled: boolean);
  69340. /**
  69341. * Specifies the number of steps used to calculate the volumetric lights
  69342. * Typically in interval [50, 200]
  69343. */
  69344. get volumetricLightStepsCount(): number;
  69345. set volumetricLightStepsCount(count: number);
  69346. /**
  69347. * Specifies the number of samples used for the motion blur effect
  69348. * Typically in interval [16, 64]
  69349. */
  69350. get motionBlurSamples(): number;
  69351. set motionBlurSamples(samples: number);
  69352. /**
  69353. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69354. */
  69355. get samples(): number;
  69356. set samples(sampleCount: number);
  69357. /**
  69358. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69359. * @constructor
  69360. * @param name The rendering pipeline name
  69361. * @param scene The scene linked to this pipeline
  69362. * @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)
  69363. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  69364. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69365. */
  69366. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  69367. private _buildPipeline;
  69368. private _createDownSampleX4PostProcess;
  69369. private _createBrightPassPostProcess;
  69370. private _createBlurPostProcesses;
  69371. private _createTextureAdderPostProcess;
  69372. private _createVolumetricLightPostProcess;
  69373. private _createLuminancePostProcesses;
  69374. private _createHdrPostProcess;
  69375. private _createLensFlarePostProcess;
  69376. private _createDepthOfFieldPostProcess;
  69377. private _createMotionBlurPostProcess;
  69378. private _getDepthTexture;
  69379. private _disposePostProcesses;
  69380. /**
  69381. * Dispose of the pipeline and stop all post processes
  69382. */
  69383. dispose(): void;
  69384. /**
  69385. * Serialize the rendering pipeline (Used when exporting)
  69386. * @returns the serialized object
  69387. */
  69388. serialize(): any;
  69389. /**
  69390. * Parse the serialized pipeline
  69391. * @param source Source pipeline.
  69392. * @param scene The scene to load the pipeline to.
  69393. * @param rootUrl The URL of the serialized pipeline.
  69394. * @returns An instantiated pipeline from the serialized object.
  69395. */
  69396. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  69397. /**
  69398. * Luminance steps
  69399. */
  69400. static LuminanceSteps: number;
  69401. }
  69402. }
  69403. declare module BABYLON {
  69404. /** @hidden */
  69405. export var stereoscopicInterlacePixelShader: {
  69406. name: string;
  69407. shader: string;
  69408. };
  69409. }
  69410. declare module BABYLON {
  69411. /**
  69412. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  69413. */
  69414. export class StereoscopicInterlacePostProcessI extends PostProcess {
  69415. private _stepSize;
  69416. private _passedProcess;
  69417. /**
  69418. * Initializes a StereoscopicInterlacePostProcessI
  69419. * @param name The name of the effect.
  69420. * @param rigCameras The rig cameras to be appled to the post process
  69421. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  69422. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  69423. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69424. * @param engine The engine which the post process will be applied. (default: current engine)
  69425. * @param reusable If the post process can be reused on the same frame. (default: false)
  69426. */
  69427. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69428. }
  69429. /**
  69430. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  69431. */
  69432. export class StereoscopicInterlacePostProcess extends PostProcess {
  69433. private _stepSize;
  69434. private _passedProcess;
  69435. /**
  69436. * Initializes a StereoscopicInterlacePostProcess
  69437. * @param name The name of the effect.
  69438. * @param rigCameras The rig cameras to be appled to the post process
  69439. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  69440. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69441. * @param engine The engine which the post process will be applied. (default: current engine)
  69442. * @param reusable If the post process can be reused on the same frame. (default: false)
  69443. */
  69444. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69445. }
  69446. }
  69447. declare module BABYLON {
  69448. /** @hidden */
  69449. export var tonemapPixelShader: {
  69450. name: string;
  69451. shader: string;
  69452. };
  69453. }
  69454. declare module BABYLON {
  69455. /** Defines operator used for tonemapping */
  69456. export enum TonemappingOperator {
  69457. /** Hable */
  69458. Hable = 0,
  69459. /** Reinhard */
  69460. Reinhard = 1,
  69461. /** HejiDawson */
  69462. HejiDawson = 2,
  69463. /** Photographic */
  69464. Photographic = 3
  69465. }
  69466. /**
  69467. * Defines a post process to apply tone mapping
  69468. */
  69469. export class TonemapPostProcess extends PostProcess {
  69470. private _operator;
  69471. /** Defines the required exposure adjustement */
  69472. exposureAdjustment: number;
  69473. /**
  69474. * Creates a new TonemapPostProcess
  69475. * @param name defines the name of the postprocess
  69476. * @param _operator defines the operator to use
  69477. * @param exposureAdjustment defines the required exposure adjustement
  69478. * @param camera defines the camera to use (can be null)
  69479. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  69480. * @param engine defines the hosting engine (can be ignore if camera is set)
  69481. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  69482. */
  69483. constructor(name: string, _operator: TonemappingOperator,
  69484. /** Defines the required exposure adjustement */
  69485. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  69486. }
  69487. }
  69488. declare module BABYLON {
  69489. /** @hidden */
  69490. export var volumetricLightScatteringPixelShader: {
  69491. name: string;
  69492. shader: string;
  69493. };
  69494. }
  69495. declare module BABYLON {
  69496. /** @hidden */
  69497. export var volumetricLightScatteringPassVertexShader: {
  69498. name: string;
  69499. shader: string;
  69500. };
  69501. }
  69502. declare module BABYLON {
  69503. /** @hidden */
  69504. export var volumetricLightScatteringPassPixelShader: {
  69505. name: string;
  69506. shader: string;
  69507. };
  69508. }
  69509. declare module BABYLON {
  69510. /**
  69511. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  69512. */
  69513. export class VolumetricLightScatteringPostProcess extends PostProcess {
  69514. private _volumetricLightScatteringPass;
  69515. private _volumetricLightScatteringRTT;
  69516. private _viewPort;
  69517. private _screenCoordinates;
  69518. private _cachedDefines;
  69519. /**
  69520. * If not undefined, the mesh position is computed from the attached node position
  69521. */
  69522. attachedNode: {
  69523. position: Vector3;
  69524. };
  69525. /**
  69526. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  69527. */
  69528. customMeshPosition: Vector3;
  69529. /**
  69530. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  69531. */
  69532. useCustomMeshPosition: boolean;
  69533. /**
  69534. * If the post-process should inverse the light scattering direction
  69535. */
  69536. invert: boolean;
  69537. /**
  69538. * The internal mesh used by the post-process
  69539. */
  69540. mesh: Mesh;
  69541. /**
  69542. * @hidden
  69543. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  69544. */
  69545. get useDiffuseColor(): boolean;
  69546. set useDiffuseColor(useDiffuseColor: boolean);
  69547. /**
  69548. * Array containing the excluded meshes not rendered in the internal pass
  69549. */
  69550. excludedMeshes: AbstractMesh[];
  69551. /**
  69552. * Controls the overall intensity of the post-process
  69553. */
  69554. exposure: number;
  69555. /**
  69556. * Dissipates each sample's contribution in range [0, 1]
  69557. */
  69558. decay: number;
  69559. /**
  69560. * Controls the overall intensity of each sample
  69561. */
  69562. weight: number;
  69563. /**
  69564. * Controls the density of each sample
  69565. */
  69566. density: number;
  69567. /**
  69568. * @constructor
  69569. * @param name The post-process name
  69570. * @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)
  69571. * @param camera The camera that the post-process will be attached to
  69572. * @param mesh The mesh used to create the light scattering
  69573. * @param samples The post-process quality, default 100
  69574. * @param samplingModeThe post-process filtering mode
  69575. * @param engine The babylon engine
  69576. * @param reusable If the post-process is reusable
  69577. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  69578. */
  69579. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  69580. /**
  69581. * Returns the string "VolumetricLightScatteringPostProcess"
  69582. * @returns "VolumetricLightScatteringPostProcess"
  69583. */
  69584. getClassName(): string;
  69585. private _isReady;
  69586. /**
  69587. * Sets the new light position for light scattering effect
  69588. * @param position The new custom light position
  69589. */
  69590. setCustomMeshPosition(position: Vector3): void;
  69591. /**
  69592. * Returns the light position for light scattering effect
  69593. * @return Vector3 The custom light position
  69594. */
  69595. getCustomMeshPosition(): Vector3;
  69596. /**
  69597. * Disposes the internal assets and detaches the post-process from the camera
  69598. */
  69599. dispose(camera: Camera): void;
  69600. /**
  69601. * Returns the render target texture used by the post-process
  69602. * @return the render target texture used by the post-process
  69603. */
  69604. getPass(): RenderTargetTexture;
  69605. private _meshExcluded;
  69606. private _createPass;
  69607. private _updateMeshScreenCoordinates;
  69608. /**
  69609. * Creates a default mesh for the Volumeric Light Scattering post-process
  69610. * @param name The mesh name
  69611. * @param scene The scene where to create the mesh
  69612. * @return the default mesh
  69613. */
  69614. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  69615. }
  69616. }
  69617. declare module BABYLON {
  69618. interface Scene {
  69619. /** @hidden (Backing field) */
  69620. _boundingBoxRenderer: BoundingBoxRenderer;
  69621. /** @hidden (Backing field) */
  69622. _forceShowBoundingBoxes: boolean;
  69623. /**
  69624. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  69625. */
  69626. forceShowBoundingBoxes: boolean;
  69627. /**
  69628. * Gets the bounding box renderer associated with the scene
  69629. * @returns a BoundingBoxRenderer
  69630. */
  69631. getBoundingBoxRenderer(): BoundingBoxRenderer;
  69632. }
  69633. interface AbstractMesh {
  69634. /** @hidden (Backing field) */
  69635. _showBoundingBox: boolean;
  69636. /**
  69637. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  69638. */
  69639. showBoundingBox: boolean;
  69640. }
  69641. /**
  69642. * Component responsible of rendering the bounding box of the meshes in a scene.
  69643. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  69644. */
  69645. export class BoundingBoxRenderer implements ISceneComponent {
  69646. /**
  69647. * The component name helpfull to identify the component in the list of scene components.
  69648. */
  69649. readonly name: string;
  69650. /**
  69651. * The scene the component belongs to.
  69652. */
  69653. scene: Scene;
  69654. /**
  69655. * Color of the bounding box lines placed in front of an object
  69656. */
  69657. frontColor: Color3;
  69658. /**
  69659. * Color of the bounding box lines placed behind an object
  69660. */
  69661. backColor: Color3;
  69662. /**
  69663. * Defines if the renderer should show the back lines or not
  69664. */
  69665. showBackLines: boolean;
  69666. /**
  69667. * Observable raised before rendering a bounding box
  69668. */
  69669. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  69670. /**
  69671. * Observable raised after rendering a bounding box
  69672. */
  69673. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  69674. /**
  69675. * @hidden
  69676. */
  69677. renderList: SmartArray<BoundingBox>;
  69678. private _colorShader;
  69679. private _vertexBuffers;
  69680. private _indexBuffer;
  69681. private _fillIndexBuffer;
  69682. private _fillIndexData;
  69683. /**
  69684. * Instantiates a new bounding box renderer in a scene.
  69685. * @param scene the scene the renderer renders in
  69686. */
  69687. constructor(scene: Scene);
  69688. /**
  69689. * Registers the component in a given scene
  69690. */
  69691. register(): void;
  69692. private _evaluateSubMesh;
  69693. private _activeMesh;
  69694. private _prepareRessources;
  69695. private _createIndexBuffer;
  69696. /**
  69697. * Rebuilds the elements related to this component in case of
  69698. * context lost for instance.
  69699. */
  69700. rebuild(): void;
  69701. /**
  69702. * @hidden
  69703. */
  69704. reset(): void;
  69705. /**
  69706. * Render the bounding boxes of a specific rendering group
  69707. * @param renderingGroupId defines the rendering group to render
  69708. */
  69709. render(renderingGroupId: number): void;
  69710. /**
  69711. * In case of occlusion queries, we can render the occlusion bounding box through this method
  69712. * @param mesh Define the mesh to render the occlusion bounding box for
  69713. */
  69714. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  69715. /**
  69716. * Dispose and release the resources attached to this renderer.
  69717. */
  69718. dispose(): void;
  69719. }
  69720. }
  69721. declare module BABYLON {
  69722. interface Scene {
  69723. /** @hidden (Backing field) */
  69724. _depthRenderer: {
  69725. [id: string]: DepthRenderer;
  69726. };
  69727. /**
  69728. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  69729. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  69730. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  69731. * @returns the created depth renderer
  69732. */
  69733. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  69734. /**
  69735. * Disables a depth renderer for a given camera
  69736. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  69737. */
  69738. disableDepthRenderer(camera?: Nullable<Camera>): void;
  69739. }
  69740. /**
  69741. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  69742. * in several rendering techniques.
  69743. */
  69744. export class DepthRendererSceneComponent implements ISceneComponent {
  69745. /**
  69746. * The component name helpfull to identify the component in the list of scene components.
  69747. */
  69748. readonly name: string;
  69749. /**
  69750. * The scene the component belongs to.
  69751. */
  69752. scene: Scene;
  69753. /**
  69754. * Creates a new instance of the component for the given scene
  69755. * @param scene Defines the scene to register the component in
  69756. */
  69757. constructor(scene: Scene);
  69758. /**
  69759. * Registers the component in a given scene
  69760. */
  69761. register(): void;
  69762. /**
  69763. * Rebuilds the elements related to this component in case of
  69764. * context lost for instance.
  69765. */
  69766. rebuild(): void;
  69767. /**
  69768. * Disposes the component and the associated ressources
  69769. */
  69770. dispose(): void;
  69771. private _gatherRenderTargets;
  69772. private _gatherActiveCameraRenderTargets;
  69773. }
  69774. }
  69775. declare module BABYLON {
  69776. /** @hidden */
  69777. export var outlinePixelShader: {
  69778. name: string;
  69779. shader: string;
  69780. };
  69781. }
  69782. declare module BABYLON {
  69783. /** @hidden */
  69784. export var outlineVertexShader: {
  69785. name: string;
  69786. shader: string;
  69787. };
  69788. }
  69789. declare module BABYLON {
  69790. interface Scene {
  69791. /** @hidden */
  69792. _outlineRenderer: OutlineRenderer;
  69793. /**
  69794. * Gets the outline renderer associated with the scene
  69795. * @returns a OutlineRenderer
  69796. */
  69797. getOutlineRenderer(): OutlineRenderer;
  69798. }
  69799. interface AbstractMesh {
  69800. /** @hidden (Backing field) */
  69801. _renderOutline: boolean;
  69802. /**
  69803. * Gets or sets a boolean indicating if the outline must be rendered as well
  69804. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  69805. */
  69806. renderOutline: boolean;
  69807. /** @hidden (Backing field) */
  69808. _renderOverlay: boolean;
  69809. /**
  69810. * Gets or sets a boolean indicating if the overlay must be rendered as well
  69811. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  69812. */
  69813. renderOverlay: boolean;
  69814. }
  69815. /**
  69816. * This class is responsible to draw bothe outline/overlay of meshes.
  69817. * It should not be used directly but through the available method on mesh.
  69818. */
  69819. export class OutlineRenderer implements ISceneComponent {
  69820. /**
  69821. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  69822. */
  69823. private static _StencilReference;
  69824. /**
  69825. * The name of the component. Each component must have a unique name.
  69826. */
  69827. name: string;
  69828. /**
  69829. * The scene the component belongs to.
  69830. */
  69831. scene: Scene;
  69832. /**
  69833. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  69834. */
  69835. zOffset: number;
  69836. private _engine;
  69837. private _effect;
  69838. private _cachedDefines;
  69839. private _savedDepthWrite;
  69840. /**
  69841. * Instantiates a new outline renderer. (There could be only one per scene).
  69842. * @param scene Defines the scene it belongs to
  69843. */
  69844. constructor(scene: Scene);
  69845. /**
  69846. * Register the component to one instance of a scene.
  69847. */
  69848. register(): void;
  69849. /**
  69850. * Rebuilds the elements related to this component in case of
  69851. * context lost for instance.
  69852. */
  69853. rebuild(): void;
  69854. /**
  69855. * Disposes the component and the associated ressources.
  69856. */
  69857. dispose(): void;
  69858. /**
  69859. * Renders the outline in the canvas.
  69860. * @param subMesh Defines the sumesh to render
  69861. * @param batch Defines the batch of meshes in case of instances
  69862. * @param useOverlay Defines if the rendering is for the overlay or the outline
  69863. */
  69864. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  69865. /**
  69866. * Returns whether or not the outline renderer is ready for a given submesh.
  69867. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  69868. * @param subMesh Defines the submesh to check readyness for
  69869. * @param useInstances Defines wheter wee are trying to render instances or not
  69870. * @returns true if ready otherwise false
  69871. */
  69872. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69873. private _beforeRenderingMesh;
  69874. private _afterRenderingMesh;
  69875. }
  69876. }
  69877. declare module BABYLON {
  69878. /**
  69879. * Defines the basic options interface of a Sprite Frame Source Size.
  69880. */
  69881. export interface ISpriteJSONSpriteSourceSize {
  69882. /**
  69883. * number of the original width of the Frame
  69884. */
  69885. w: number;
  69886. /**
  69887. * number of the original height of the Frame
  69888. */
  69889. h: number;
  69890. }
  69891. /**
  69892. * Defines the basic options interface of a Sprite Frame Data.
  69893. */
  69894. export interface ISpriteJSONSpriteFrameData {
  69895. /**
  69896. * number of the x offset of the Frame
  69897. */
  69898. x: number;
  69899. /**
  69900. * number of the y offset of the Frame
  69901. */
  69902. y: number;
  69903. /**
  69904. * number of the width of the Frame
  69905. */
  69906. w: number;
  69907. /**
  69908. * number of the height of the Frame
  69909. */
  69910. h: number;
  69911. }
  69912. /**
  69913. * Defines the basic options interface of a JSON Sprite.
  69914. */
  69915. export interface ISpriteJSONSprite {
  69916. /**
  69917. * string name of the Frame
  69918. */
  69919. filename: string;
  69920. /**
  69921. * ISpriteJSONSpriteFrame basic object of the frame data
  69922. */
  69923. frame: ISpriteJSONSpriteFrameData;
  69924. /**
  69925. * boolean to flag is the frame was rotated.
  69926. */
  69927. rotated: boolean;
  69928. /**
  69929. * boolean to flag is the frame was trimmed.
  69930. */
  69931. trimmed: boolean;
  69932. /**
  69933. * ISpriteJSONSpriteFrame basic object of the source data
  69934. */
  69935. spriteSourceSize: ISpriteJSONSpriteFrameData;
  69936. /**
  69937. * ISpriteJSONSpriteFrame basic object of the source data
  69938. */
  69939. sourceSize: ISpriteJSONSpriteSourceSize;
  69940. }
  69941. /**
  69942. * Defines the basic options interface of a JSON atlas.
  69943. */
  69944. export interface ISpriteJSONAtlas {
  69945. /**
  69946. * Array of objects that contain the frame data.
  69947. */
  69948. frames: Array<ISpriteJSONSprite>;
  69949. /**
  69950. * object basic object containing the sprite meta data.
  69951. */
  69952. meta?: object;
  69953. }
  69954. }
  69955. declare module BABYLON {
  69956. /** @hidden */
  69957. export var spriteMapPixelShader: {
  69958. name: string;
  69959. shader: string;
  69960. };
  69961. }
  69962. declare module BABYLON {
  69963. /** @hidden */
  69964. export var spriteMapVertexShader: {
  69965. name: string;
  69966. shader: string;
  69967. };
  69968. }
  69969. declare module BABYLON {
  69970. /**
  69971. * Defines the basic options interface of a SpriteMap
  69972. */
  69973. export interface ISpriteMapOptions {
  69974. /**
  69975. * Vector2 of the number of cells in the grid.
  69976. */
  69977. stageSize?: Vector2;
  69978. /**
  69979. * Vector2 of the size of the output plane in World Units.
  69980. */
  69981. outputSize?: Vector2;
  69982. /**
  69983. * Vector3 of the position of the output plane in World Units.
  69984. */
  69985. outputPosition?: Vector3;
  69986. /**
  69987. * Vector3 of the rotation of the output plane.
  69988. */
  69989. outputRotation?: Vector3;
  69990. /**
  69991. * number of layers that the system will reserve in resources.
  69992. */
  69993. layerCount?: number;
  69994. /**
  69995. * number of max animation frames a single cell will reserve in resources.
  69996. */
  69997. maxAnimationFrames?: number;
  69998. /**
  69999. * number cell index of the base tile when the system compiles.
  70000. */
  70001. baseTile?: number;
  70002. /**
  70003. * boolean flip the sprite after its been repositioned by the framing data.
  70004. */
  70005. flipU?: boolean;
  70006. /**
  70007. * Vector3 scalar of the global RGB values of the SpriteMap.
  70008. */
  70009. colorMultiply?: Vector3;
  70010. }
  70011. /**
  70012. * Defines the IDisposable interface in order to be cleanable from resources.
  70013. */
  70014. export interface ISpriteMap extends IDisposable {
  70015. /**
  70016. * String name of the SpriteMap.
  70017. */
  70018. name: string;
  70019. /**
  70020. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  70021. */
  70022. atlasJSON: ISpriteJSONAtlas;
  70023. /**
  70024. * Texture of the SpriteMap.
  70025. */
  70026. spriteSheet: Texture;
  70027. /**
  70028. * The parameters to initialize the SpriteMap with.
  70029. */
  70030. options: ISpriteMapOptions;
  70031. }
  70032. /**
  70033. * Class used to manage a grid restricted sprite deployment on an Output plane.
  70034. */
  70035. export class SpriteMap implements ISpriteMap {
  70036. /** The Name of the spriteMap */
  70037. name: string;
  70038. /** The JSON file with the frame and meta data */
  70039. atlasJSON: ISpriteJSONAtlas;
  70040. /** The systems Sprite Sheet Texture */
  70041. spriteSheet: Texture;
  70042. /** Arguments passed with the Constructor */
  70043. options: ISpriteMapOptions;
  70044. /** Public Sprite Storage array, parsed from atlasJSON */
  70045. sprites: Array<ISpriteJSONSprite>;
  70046. /** Returns the Number of Sprites in the System */
  70047. get spriteCount(): number;
  70048. /** Returns the Position of Output Plane*/
  70049. get position(): Vector3;
  70050. /** Returns the Position of Output Plane*/
  70051. set position(v: Vector3);
  70052. /** Returns the Rotation of Output Plane*/
  70053. get rotation(): Vector3;
  70054. /** Returns the Rotation of Output Plane*/
  70055. set rotation(v: Vector3);
  70056. /** Sets the AnimationMap*/
  70057. get animationMap(): RawTexture;
  70058. /** Sets the AnimationMap*/
  70059. set animationMap(v: RawTexture);
  70060. /** Scene that the SpriteMap was created in */
  70061. private _scene;
  70062. /** Texture Buffer of Float32 that holds tile frame data*/
  70063. private _frameMap;
  70064. /** Texture Buffers of Float32 that holds tileMap data*/
  70065. private _tileMaps;
  70066. /** Texture Buffer of Float32 that holds Animation Data*/
  70067. private _animationMap;
  70068. /** Custom ShaderMaterial Central to the System*/
  70069. private _material;
  70070. /** Custom ShaderMaterial Central to the System*/
  70071. private _output;
  70072. /** Systems Time Ticker*/
  70073. private _time;
  70074. /**
  70075. * Creates a new SpriteMap
  70076. * @param name defines the SpriteMaps Name
  70077. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  70078. * @param spriteSheet is the Texture that the Sprites are on.
  70079. * @param options a basic deployment configuration
  70080. * @param scene The Scene that the map is deployed on
  70081. */
  70082. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  70083. /**
  70084. * Returns tileID location
  70085. * @returns Vector2 the cell position ID
  70086. */
  70087. getTileID(): Vector2;
  70088. /**
  70089. * Gets the UV location of the mouse over the SpriteMap.
  70090. * @returns Vector2 the UV position of the mouse interaction
  70091. */
  70092. getMousePosition(): Vector2;
  70093. /**
  70094. * Creates the "frame" texture Buffer
  70095. * -------------------------------------
  70096. * Structure of frames
  70097. * "filename": "Falling-Water-2.png",
  70098. * "frame": {"x":69,"y":103,"w":24,"h":32},
  70099. * "rotated": true,
  70100. * "trimmed": true,
  70101. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  70102. * "sourceSize": {"w":32,"h":32}
  70103. * @returns RawTexture of the frameMap
  70104. */
  70105. private _createFrameBuffer;
  70106. /**
  70107. * Creates the tileMap texture Buffer
  70108. * @param buffer normally and array of numbers, or a false to generate from scratch
  70109. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  70110. * @returns RawTexture of the tileMap
  70111. */
  70112. private _createTileBuffer;
  70113. /**
  70114. * Modifies the data of the tileMaps
  70115. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  70116. * @param pos is the iVector2 Coordinates of the Tile
  70117. * @param tile The SpriteIndex of the new Tile
  70118. */
  70119. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  70120. /**
  70121. * Creates the animationMap texture Buffer
  70122. * @param buffer normally and array of numbers, or a false to generate from scratch
  70123. * @returns RawTexture of the animationMap
  70124. */
  70125. private _createTileAnimationBuffer;
  70126. /**
  70127. * Modifies the data of the animationMap
  70128. * @param cellID is the Index of the Sprite
  70129. * @param _frame is the target Animation frame
  70130. * @param toCell is the Target Index of the next frame of the animation
  70131. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  70132. * @param speed is a global scalar of the time variable on the map.
  70133. */
  70134. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  70135. /**
  70136. * Exports the .tilemaps file
  70137. */
  70138. saveTileMaps(): void;
  70139. /**
  70140. * Imports the .tilemaps file
  70141. * @param url of the .tilemaps file
  70142. */
  70143. loadTileMaps(url: string): void;
  70144. /**
  70145. * Release associated resources
  70146. */
  70147. dispose(): void;
  70148. }
  70149. }
  70150. declare module BABYLON {
  70151. /**
  70152. * Class used to manage multiple sprites of different sizes on the same spritesheet
  70153. * @see http://doc.babylonjs.com/babylon101/sprites
  70154. */
  70155. export class SpritePackedManager extends SpriteManager {
  70156. /** defines the packed manager's name */
  70157. name: string;
  70158. /**
  70159. * Creates a new sprite manager from a packed sprite sheet
  70160. * @param name defines the manager's name
  70161. * @param imgUrl defines the sprite sheet url
  70162. * @param capacity defines the maximum allowed number of sprites
  70163. * @param scene defines the hosting scene
  70164. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  70165. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70166. * @param samplingMode defines the smapling mode to use with spritesheet
  70167. * @param fromPacked set to true; do not alter
  70168. */
  70169. constructor(
  70170. /** defines the packed manager's name */
  70171. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  70172. }
  70173. }
  70174. declare module BABYLON {
  70175. /**
  70176. * Defines the list of states available for a task inside a AssetsManager
  70177. */
  70178. export enum AssetTaskState {
  70179. /**
  70180. * Initialization
  70181. */
  70182. INIT = 0,
  70183. /**
  70184. * Running
  70185. */
  70186. RUNNING = 1,
  70187. /**
  70188. * Done
  70189. */
  70190. DONE = 2,
  70191. /**
  70192. * Error
  70193. */
  70194. ERROR = 3
  70195. }
  70196. /**
  70197. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  70198. */
  70199. export abstract class AbstractAssetTask {
  70200. /**
  70201. * Task name
  70202. */ name: string;
  70203. /**
  70204. * Callback called when the task is successful
  70205. */
  70206. onSuccess: (task: any) => void;
  70207. /**
  70208. * Callback called when the task is not successful
  70209. */
  70210. onError: (task: any, message?: string, exception?: any) => void;
  70211. /**
  70212. * Creates a new AssetsManager
  70213. * @param name defines the name of the task
  70214. */
  70215. constructor(
  70216. /**
  70217. * Task name
  70218. */ name: string);
  70219. private _isCompleted;
  70220. private _taskState;
  70221. private _errorObject;
  70222. /**
  70223. * Get if the task is completed
  70224. */
  70225. get isCompleted(): boolean;
  70226. /**
  70227. * Gets the current state of the task
  70228. */
  70229. get taskState(): AssetTaskState;
  70230. /**
  70231. * Gets the current error object (if task is in error)
  70232. */
  70233. get errorObject(): {
  70234. message?: string;
  70235. exception?: any;
  70236. };
  70237. /**
  70238. * Internal only
  70239. * @hidden
  70240. */
  70241. _setErrorObject(message?: string, exception?: any): void;
  70242. /**
  70243. * Execute the current task
  70244. * @param scene defines the scene where you want your assets to be loaded
  70245. * @param onSuccess is a callback called when the task is successfully executed
  70246. * @param onError is a callback called if an error occurs
  70247. */
  70248. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70249. /**
  70250. * Execute the current task
  70251. * @param scene defines the scene where you want your assets to be loaded
  70252. * @param onSuccess is a callback called when the task is successfully executed
  70253. * @param onError is a callback called if an error occurs
  70254. */
  70255. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70256. /**
  70257. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  70258. * This can be used with failed tasks that have the reason for failure fixed.
  70259. */
  70260. reset(): void;
  70261. private onErrorCallback;
  70262. private onDoneCallback;
  70263. }
  70264. /**
  70265. * Define the interface used by progress events raised during assets loading
  70266. */
  70267. export interface IAssetsProgressEvent {
  70268. /**
  70269. * Defines the number of remaining tasks to process
  70270. */
  70271. remainingCount: number;
  70272. /**
  70273. * Defines the total number of tasks
  70274. */
  70275. totalCount: number;
  70276. /**
  70277. * Defines the task that was just processed
  70278. */
  70279. task: AbstractAssetTask;
  70280. }
  70281. /**
  70282. * Class used to share progress information about assets loading
  70283. */
  70284. export class AssetsProgressEvent implements IAssetsProgressEvent {
  70285. /**
  70286. * Defines the number of remaining tasks to process
  70287. */
  70288. remainingCount: number;
  70289. /**
  70290. * Defines the total number of tasks
  70291. */
  70292. totalCount: number;
  70293. /**
  70294. * Defines the task that was just processed
  70295. */
  70296. task: AbstractAssetTask;
  70297. /**
  70298. * Creates a AssetsProgressEvent
  70299. * @param remainingCount defines the number of remaining tasks to process
  70300. * @param totalCount defines the total number of tasks
  70301. * @param task defines the task that was just processed
  70302. */
  70303. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  70304. }
  70305. /**
  70306. * Define a task used by AssetsManager to load meshes
  70307. */
  70308. export class MeshAssetTask extends AbstractAssetTask {
  70309. /**
  70310. * Defines the name of the task
  70311. */
  70312. name: string;
  70313. /**
  70314. * Defines the list of mesh's names you want to load
  70315. */
  70316. meshesNames: any;
  70317. /**
  70318. * Defines the root url to use as a base to load your meshes and associated resources
  70319. */
  70320. rootUrl: string;
  70321. /**
  70322. * Defines the filename or File of the scene to load from
  70323. */
  70324. sceneFilename: string | File;
  70325. /**
  70326. * Gets the list of loaded meshes
  70327. */
  70328. loadedMeshes: Array<AbstractMesh>;
  70329. /**
  70330. * Gets the list of loaded particle systems
  70331. */
  70332. loadedParticleSystems: Array<IParticleSystem>;
  70333. /**
  70334. * Gets the list of loaded skeletons
  70335. */
  70336. loadedSkeletons: Array<Skeleton>;
  70337. /**
  70338. * Gets the list of loaded animation groups
  70339. */
  70340. loadedAnimationGroups: Array<AnimationGroup>;
  70341. /**
  70342. * Callback called when the task is successful
  70343. */
  70344. onSuccess: (task: MeshAssetTask) => void;
  70345. /**
  70346. * Callback called when the task is successful
  70347. */
  70348. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  70349. /**
  70350. * Creates a new MeshAssetTask
  70351. * @param name defines the name of the task
  70352. * @param meshesNames defines the list of mesh's names you want to load
  70353. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  70354. * @param sceneFilename defines the filename or File of the scene to load from
  70355. */
  70356. constructor(
  70357. /**
  70358. * Defines the name of the task
  70359. */
  70360. name: string,
  70361. /**
  70362. * Defines the list of mesh's names you want to load
  70363. */
  70364. meshesNames: any,
  70365. /**
  70366. * Defines the root url to use as a base to load your meshes and associated resources
  70367. */
  70368. rootUrl: string,
  70369. /**
  70370. * Defines the filename or File of the scene to load from
  70371. */
  70372. sceneFilename: string | File);
  70373. /**
  70374. * Execute the current task
  70375. * @param scene defines the scene where you want your assets to be loaded
  70376. * @param onSuccess is a callback called when the task is successfully executed
  70377. * @param onError is a callback called if an error occurs
  70378. */
  70379. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70380. }
  70381. /**
  70382. * Define a task used by AssetsManager to load text content
  70383. */
  70384. export class TextFileAssetTask extends AbstractAssetTask {
  70385. /**
  70386. * Defines the name of the task
  70387. */
  70388. name: string;
  70389. /**
  70390. * Defines the location of the file to load
  70391. */
  70392. url: string;
  70393. /**
  70394. * Gets the loaded text string
  70395. */
  70396. text: string;
  70397. /**
  70398. * Callback called when the task is successful
  70399. */
  70400. onSuccess: (task: TextFileAssetTask) => void;
  70401. /**
  70402. * Callback called when the task is successful
  70403. */
  70404. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  70405. /**
  70406. * Creates a new TextFileAssetTask object
  70407. * @param name defines the name of the task
  70408. * @param url defines the location of the file to load
  70409. */
  70410. constructor(
  70411. /**
  70412. * Defines the name of the task
  70413. */
  70414. name: string,
  70415. /**
  70416. * Defines the location of the file to load
  70417. */
  70418. url: string);
  70419. /**
  70420. * Execute the current task
  70421. * @param scene defines the scene where you want your assets to be loaded
  70422. * @param onSuccess is a callback called when the task is successfully executed
  70423. * @param onError is a callback called if an error occurs
  70424. */
  70425. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70426. }
  70427. /**
  70428. * Define a task used by AssetsManager to load binary data
  70429. */
  70430. export class BinaryFileAssetTask extends AbstractAssetTask {
  70431. /**
  70432. * Defines the name of the task
  70433. */
  70434. name: string;
  70435. /**
  70436. * Defines the location of the file to load
  70437. */
  70438. url: string;
  70439. /**
  70440. * Gets the lodaded data (as an array buffer)
  70441. */
  70442. data: ArrayBuffer;
  70443. /**
  70444. * Callback called when the task is successful
  70445. */
  70446. onSuccess: (task: BinaryFileAssetTask) => void;
  70447. /**
  70448. * Callback called when the task is successful
  70449. */
  70450. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  70451. /**
  70452. * Creates a new BinaryFileAssetTask object
  70453. * @param name defines the name of the new task
  70454. * @param url defines the location of the file to load
  70455. */
  70456. constructor(
  70457. /**
  70458. * Defines the name of the task
  70459. */
  70460. name: string,
  70461. /**
  70462. * Defines the location of the file to load
  70463. */
  70464. url: string);
  70465. /**
  70466. * Execute the current task
  70467. * @param scene defines the scene where you want your assets to be loaded
  70468. * @param onSuccess is a callback called when the task is successfully executed
  70469. * @param onError is a callback called if an error occurs
  70470. */
  70471. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70472. }
  70473. /**
  70474. * Define a task used by AssetsManager to load images
  70475. */
  70476. export class ImageAssetTask extends AbstractAssetTask {
  70477. /**
  70478. * Defines the name of the task
  70479. */
  70480. name: string;
  70481. /**
  70482. * Defines the location of the image to load
  70483. */
  70484. url: string;
  70485. /**
  70486. * Gets the loaded images
  70487. */
  70488. image: HTMLImageElement;
  70489. /**
  70490. * Callback called when the task is successful
  70491. */
  70492. onSuccess: (task: ImageAssetTask) => void;
  70493. /**
  70494. * Callback called when the task is successful
  70495. */
  70496. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  70497. /**
  70498. * Creates a new ImageAssetTask
  70499. * @param name defines the name of the task
  70500. * @param url defines the location of the image to load
  70501. */
  70502. constructor(
  70503. /**
  70504. * Defines the name of the task
  70505. */
  70506. name: string,
  70507. /**
  70508. * Defines the location of the image to load
  70509. */
  70510. url: string);
  70511. /**
  70512. * Execute the current task
  70513. * @param scene defines the scene where you want your assets to be loaded
  70514. * @param onSuccess is a callback called when the task is successfully executed
  70515. * @param onError is a callback called if an error occurs
  70516. */
  70517. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70518. }
  70519. /**
  70520. * Defines the interface used by texture loading tasks
  70521. */
  70522. export interface ITextureAssetTask<TEX extends BaseTexture> {
  70523. /**
  70524. * Gets the loaded texture
  70525. */
  70526. texture: TEX;
  70527. }
  70528. /**
  70529. * Define a task used by AssetsManager to load 2D textures
  70530. */
  70531. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  70532. /**
  70533. * Defines the name of the task
  70534. */
  70535. name: string;
  70536. /**
  70537. * Defines the location of the file to load
  70538. */
  70539. url: string;
  70540. /**
  70541. * Defines if mipmap should not be generated (default is false)
  70542. */
  70543. noMipmap?: boolean | undefined;
  70544. /**
  70545. * Defines if texture must be inverted on Y axis (default is true)
  70546. */
  70547. invertY: boolean;
  70548. /**
  70549. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70550. */
  70551. samplingMode: number;
  70552. /**
  70553. * Gets the loaded texture
  70554. */
  70555. texture: Texture;
  70556. /**
  70557. * Callback called when the task is successful
  70558. */
  70559. onSuccess: (task: TextureAssetTask) => void;
  70560. /**
  70561. * Callback called when the task is successful
  70562. */
  70563. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  70564. /**
  70565. * Creates a new TextureAssetTask object
  70566. * @param name defines the name of the task
  70567. * @param url defines the location of the file to load
  70568. * @param noMipmap defines if mipmap should not be generated (default is false)
  70569. * @param invertY defines if texture must be inverted on Y axis (default is true)
  70570. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70571. */
  70572. constructor(
  70573. /**
  70574. * Defines the name of the task
  70575. */
  70576. name: string,
  70577. /**
  70578. * Defines the location of the file to load
  70579. */
  70580. url: string,
  70581. /**
  70582. * Defines if mipmap should not be generated (default is false)
  70583. */
  70584. noMipmap?: boolean | undefined,
  70585. /**
  70586. * Defines if texture must be inverted on Y axis (default is true)
  70587. */
  70588. invertY?: boolean,
  70589. /**
  70590. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70591. */
  70592. samplingMode?: number);
  70593. /**
  70594. * Execute the current task
  70595. * @param scene defines the scene where you want your assets to be loaded
  70596. * @param onSuccess is a callback called when the task is successfully executed
  70597. * @param onError is a callback called if an error occurs
  70598. */
  70599. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70600. }
  70601. /**
  70602. * Define a task used by AssetsManager to load cube textures
  70603. */
  70604. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  70605. /**
  70606. * Defines the name of the task
  70607. */
  70608. name: string;
  70609. /**
  70610. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  70611. */
  70612. url: string;
  70613. /**
  70614. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  70615. */
  70616. extensions?: string[] | undefined;
  70617. /**
  70618. * Defines if mipmaps should not be generated (default is false)
  70619. */
  70620. noMipmap?: boolean | undefined;
  70621. /**
  70622. * Defines the explicit list of files (undefined by default)
  70623. */
  70624. files?: string[] | undefined;
  70625. /**
  70626. * Gets the loaded texture
  70627. */
  70628. texture: CubeTexture;
  70629. /**
  70630. * Callback called when the task is successful
  70631. */
  70632. onSuccess: (task: CubeTextureAssetTask) => void;
  70633. /**
  70634. * Callback called when the task is successful
  70635. */
  70636. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  70637. /**
  70638. * Creates a new CubeTextureAssetTask
  70639. * @param name defines the name of the task
  70640. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  70641. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  70642. * @param noMipmap defines if mipmaps should not be generated (default is false)
  70643. * @param files defines the explicit list of files (undefined by default)
  70644. */
  70645. constructor(
  70646. /**
  70647. * Defines the name of the task
  70648. */
  70649. name: string,
  70650. /**
  70651. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  70652. */
  70653. url: string,
  70654. /**
  70655. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  70656. */
  70657. extensions?: string[] | undefined,
  70658. /**
  70659. * Defines if mipmaps should not be generated (default is false)
  70660. */
  70661. noMipmap?: boolean | undefined,
  70662. /**
  70663. * Defines the explicit list of files (undefined by default)
  70664. */
  70665. files?: string[] | undefined);
  70666. /**
  70667. * Execute the current task
  70668. * @param scene defines the scene where you want your assets to be loaded
  70669. * @param onSuccess is a callback called when the task is successfully executed
  70670. * @param onError is a callback called if an error occurs
  70671. */
  70672. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70673. }
  70674. /**
  70675. * Define a task used by AssetsManager to load HDR cube textures
  70676. */
  70677. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  70678. /**
  70679. * Defines the name of the task
  70680. */
  70681. name: string;
  70682. /**
  70683. * Defines the location of the file to load
  70684. */
  70685. url: string;
  70686. /**
  70687. * Defines the desired size (the more it increases the longer the generation will be)
  70688. */
  70689. size: number;
  70690. /**
  70691. * Defines if mipmaps should not be generated (default is false)
  70692. */
  70693. noMipmap: boolean;
  70694. /**
  70695. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  70696. */
  70697. generateHarmonics: boolean;
  70698. /**
  70699. * 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)
  70700. */
  70701. gammaSpace: boolean;
  70702. /**
  70703. * Internal Use Only
  70704. */
  70705. reserved: boolean;
  70706. /**
  70707. * Gets the loaded texture
  70708. */
  70709. texture: HDRCubeTexture;
  70710. /**
  70711. * Callback called when the task is successful
  70712. */
  70713. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  70714. /**
  70715. * Callback called when the task is successful
  70716. */
  70717. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  70718. /**
  70719. * Creates a new HDRCubeTextureAssetTask object
  70720. * @param name defines the name of the task
  70721. * @param url defines the location of the file to load
  70722. * @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.
  70723. * @param noMipmap defines if mipmaps should not be generated (default is false)
  70724. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  70725. * @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)
  70726. * @param reserved Internal use only
  70727. */
  70728. constructor(
  70729. /**
  70730. * Defines the name of the task
  70731. */
  70732. name: string,
  70733. /**
  70734. * Defines the location of the file to load
  70735. */
  70736. url: string,
  70737. /**
  70738. * Defines the desired size (the more it increases the longer the generation will be)
  70739. */
  70740. size: number,
  70741. /**
  70742. * Defines if mipmaps should not be generated (default is false)
  70743. */
  70744. noMipmap?: boolean,
  70745. /**
  70746. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  70747. */
  70748. generateHarmonics?: boolean,
  70749. /**
  70750. * 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)
  70751. */
  70752. gammaSpace?: boolean,
  70753. /**
  70754. * Internal Use Only
  70755. */
  70756. reserved?: boolean);
  70757. /**
  70758. * Execute the current task
  70759. * @param scene defines the scene where you want your assets to be loaded
  70760. * @param onSuccess is a callback called when the task is successfully executed
  70761. * @param onError is a callback called if an error occurs
  70762. */
  70763. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70764. }
  70765. /**
  70766. * Define a task used by AssetsManager to load Equirectangular cube textures
  70767. */
  70768. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  70769. /**
  70770. * Defines the name of the task
  70771. */
  70772. name: string;
  70773. /**
  70774. * Defines the location of the file to load
  70775. */
  70776. url: string;
  70777. /**
  70778. * Defines the desired size (the more it increases the longer the generation will be)
  70779. */
  70780. size: number;
  70781. /**
  70782. * Defines if mipmaps should not be generated (default is false)
  70783. */
  70784. noMipmap: boolean;
  70785. /**
  70786. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  70787. * but the standard material would require them in Gamma space) (default is true)
  70788. */
  70789. gammaSpace: boolean;
  70790. /**
  70791. * Gets the loaded texture
  70792. */
  70793. texture: EquiRectangularCubeTexture;
  70794. /**
  70795. * Callback called when the task is successful
  70796. */
  70797. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  70798. /**
  70799. * Callback called when the task is successful
  70800. */
  70801. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  70802. /**
  70803. * Creates a new EquiRectangularCubeTextureAssetTask object
  70804. * @param name defines the name of the task
  70805. * @param url defines the location of the file to load
  70806. * @param size defines the desired size (the more it increases the longer the generation will be)
  70807. * If the size is omitted this implies you are using a preprocessed cubemap.
  70808. * @param noMipmap defines if mipmaps should not be generated (default is false)
  70809. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  70810. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  70811. * (default is true)
  70812. */
  70813. constructor(
  70814. /**
  70815. * Defines the name of the task
  70816. */
  70817. name: string,
  70818. /**
  70819. * Defines the location of the file to load
  70820. */
  70821. url: string,
  70822. /**
  70823. * Defines the desired size (the more it increases the longer the generation will be)
  70824. */
  70825. size: number,
  70826. /**
  70827. * Defines if mipmaps should not be generated (default is false)
  70828. */
  70829. noMipmap?: boolean,
  70830. /**
  70831. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  70832. * but the standard material would require them in Gamma space) (default is true)
  70833. */
  70834. gammaSpace?: boolean);
  70835. /**
  70836. * Execute the current task
  70837. * @param scene defines the scene where you want your assets to be loaded
  70838. * @param onSuccess is a callback called when the task is successfully executed
  70839. * @param onError is a callback called if an error occurs
  70840. */
  70841. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70842. }
  70843. /**
  70844. * This class can be used to easily import assets into a scene
  70845. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  70846. */
  70847. export class AssetsManager {
  70848. private _scene;
  70849. private _isLoading;
  70850. protected _tasks: AbstractAssetTask[];
  70851. protected _waitingTasksCount: number;
  70852. protected _totalTasksCount: number;
  70853. /**
  70854. * Callback called when all tasks are processed
  70855. */
  70856. onFinish: (tasks: AbstractAssetTask[]) => void;
  70857. /**
  70858. * Callback called when a task is successful
  70859. */
  70860. onTaskSuccess: (task: AbstractAssetTask) => void;
  70861. /**
  70862. * Callback called when a task had an error
  70863. */
  70864. onTaskError: (task: AbstractAssetTask) => void;
  70865. /**
  70866. * Callback called when a task is done (whatever the result is)
  70867. */
  70868. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  70869. /**
  70870. * Observable called when all tasks are processed
  70871. */
  70872. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  70873. /**
  70874. * Observable called when a task had an error
  70875. */
  70876. onTaskErrorObservable: Observable<AbstractAssetTask>;
  70877. /**
  70878. * Observable called when all tasks were executed
  70879. */
  70880. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  70881. /**
  70882. * Observable called when a task is done (whatever the result is)
  70883. */
  70884. onProgressObservable: Observable<IAssetsProgressEvent>;
  70885. /**
  70886. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  70887. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  70888. */
  70889. useDefaultLoadingScreen: boolean;
  70890. /**
  70891. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  70892. * when all assets have been downloaded.
  70893. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  70894. */
  70895. autoHideLoadingUI: boolean;
  70896. /**
  70897. * Creates a new AssetsManager
  70898. * @param scene defines the scene to work on
  70899. */
  70900. constructor(scene: Scene);
  70901. /**
  70902. * Add a MeshAssetTask to the list of active tasks
  70903. * @param taskName defines the name of the new task
  70904. * @param meshesNames defines the name of meshes to load
  70905. * @param rootUrl defines the root url to use to locate files
  70906. * @param sceneFilename defines the filename of the scene file
  70907. * @returns a new MeshAssetTask object
  70908. */
  70909. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  70910. /**
  70911. * Add a TextFileAssetTask to the list of active tasks
  70912. * @param taskName defines the name of the new task
  70913. * @param url defines the url of the file to load
  70914. * @returns a new TextFileAssetTask object
  70915. */
  70916. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  70917. /**
  70918. * Add a BinaryFileAssetTask to the list of active tasks
  70919. * @param taskName defines the name of the new task
  70920. * @param url defines the url of the file to load
  70921. * @returns a new BinaryFileAssetTask object
  70922. */
  70923. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  70924. /**
  70925. * Add a ImageAssetTask to the list of active tasks
  70926. * @param taskName defines the name of the new task
  70927. * @param url defines the url of the file to load
  70928. * @returns a new ImageAssetTask object
  70929. */
  70930. addImageTask(taskName: string, url: string): ImageAssetTask;
  70931. /**
  70932. * Add a TextureAssetTask to the list of active tasks
  70933. * @param taskName defines the name of the new task
  70934. * @param url defines the url of the file to load
  70935. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  70936. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  70937. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  70938. * @returns a new TextureAssetTask object
  70939. */
  70940. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  70941. /**
  70942. * Add a CubeTextureAssetTask to the list of active tasks
  70943. * @param taskName defines the name of the new task
  70944. * @param url defines the url of the file to load
  70945. * @param extensions defines the extension to use to load the cube map (can be null)
  70946. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  70947. * @param files defines the list of files to load (can be null)
  70948. * @returns a new CubeTextureAssetTask object
  70949. */
  70950. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  70951. /**
  70952. *
  70953. * Add a HDRCubeTextureAssetTask to the list of active tasks
  70954. * @param taskName defines the name of the new task
  70955. * @param url defines the url of the file to load
  70956. * @param size defines the size you want for the cubemap (can be null)
  70957. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  70958. * @param generateHarmonics defines if you want to automatically generate (true by default)
  70959. * @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)
  70960. * @param reserved Internal use only
  70961. * @returns a new HDRCubeTextureAssetTask object
  70962. */
  70963. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  70964. /**
  70965. *
  70966. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  70967. * @param taskName defines the name of the new task
  70968. * @param url defines the url of the file to load
  70969. * @param size defines the size you want for the cubemap (can be null)
  70970. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  70971. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  70972. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  70973. * @returns a new EquiRectangularCubeTextureAssetTask object
  70974. */
  70975. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  70976. /**
  70977. * Remove a task from the assets manager.
  70978. * @param task the task to remove
  70979. */
  70980. removeTask(task: AbstractAssetTask): void;
  70981. private _decreaseWaitingTasksCount;
  70982. private _runTask;
  70983. /**
  70984. * Reset the AssetsManager and remove all tasks
  70985. * @return the current instance of the AssetsManager
  70986. */
  70987. reset(): AssetsManager;
  70988. /**
  70989. * Start the loading process
  70990. * @return the current instance of the AssetsManager
  70991. */
  70992. load(): AssetsManager;
  70993. /**
  70994. * Start the loading process as an async operation
  70995. * @return a promise returning the list of failed tasks
  70996. */
  70997. loadAsync(): Promise<void>;
  70998. }
  70999. }
  71000. declare module BABYLON {
  71001. /**
  71002. * Wrapper class for promise with external resolve and reject.
  71003. */
  71004. export class Deferred<T> {
  71005. /**
  71006. * The promise associated with this deferred object.
  71007. */
  71008. readonly promise: Promise<T>;
  71009. private _resolve;
  71010. private _reject;
  71011. /**
  71012. * The resolve method of the promise associated with this deferred object.
  71013. */
  71014. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  71015. /**
  71016. * The reject method of the promise associated with this deferred object.
  71017. */
  71018. get reject(): (reason?: any) => void;
  71019. /**
  71020. * Constructor for this deferred object.
  71021. */
  71022. constructor();
  71023. }
  71024. }
  71025. declare module BABYLON {
  71026. /**
  71027. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  71028. */
  71029. export class MeshExploder {
  71030. private _centerMesh;
  71031. private _meshes;
  71032. private _meshesOrigins;
  71033. private _toCenterVectors;
  71034. private _scaledDirection;
  71035. private _newPosition;
  71036. private _centerPosition;
  71037. /**
  71038. * Explodes meshes from a center mesh.
  71039. * @param meshes The meshes to explode.
  71040. * @param centerMesh The mesh to be center of explosion.
  71041. */
  71042. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  71043. private _setCenterMesh;
  71044. /**
  71045. * Get class name
  71046. * @returns "MeshExploder"
  71047. */
  71048. getClassName(): string;
  71049. /**
  71050. * "Exploded meshes"
  71051. * @returns Array of meshes with the centerMesh at index 0.
  71052. */
  71053. getMeshes(): Array<Mesh>;
  71054. /**
  71055. * Explodes meshes giving a specific direction
  71056. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  71057. */
  71058. explode(direction?: number): void;
  71059. }
  71060. }
  71061. declare module BABYLON {
  71062. /**
  71063. * Class used to help managing file picking and drag'n'drop
  71064. */
  71065. export class FilesInput {
  71066. /**
  71067. * List of files ready to be loaded
  71068. */
  71069. static get FilesToLoad(): {
  71070. [key: string]: File;
  71071. };
  71072. /**
  71073. * Callback called when a file is processed
  71074. */
  71075. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  71076. private _engine;
  71077. private _currentScene;
  71078. private _sceneLoadedCallback;
  71079. private _progressCallback;
  71080. private _additionalRenderLoopLogicCallback;
  71081. private _textureLoadingCallback;
  71082. private _startingProcessingFilesCallback;
  71083. private _onReloadCallback;
  71084. private _errorCallback;
  71085. private _elementToMonitor;
  71086. private _sceneFileToLoad;
  71087. private _filesToLoad;
  71088. /**
  71089. * Creates a new FilesInput
  71090. * @param engine defines the rendering engine
  71091. * @param scene defines the hosting scene
  71092. * @param sceneLoadedCallback callback called when scene is loaded
  71093. * @param progressCallback callback called to track progress
  71094. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  71095. * @param textureLoadingCallback callback called when a texture is loading
  71096. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  71097. * @param onReloadCallback callback called when a reload is requested
  71098. * @param errorCallback callback call if an error occurs
  71099. */
  71100. 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);
  71101. private _dragEnterHandler;
  71102. private _dragOverHandler;
  71103. private _dropHandler;
  71104. /**
  71105. * Calls this function to listen to drag'n'drop events on a specific DOM element
  71106. * @param elementToMonitor defines the DOM element to track
  71107. */
  71108. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  71109. /**
  71110. * Release all associated resources
  71111. */
  71112. dispose(): void;
  71113. private renderFunction;
  71114. private drag;
  71115. private drop;
  71116. private _traverseFolder;
  71117. private _processFiles;
  71118. /**
  71119. * Load files from a drop event
  71120. * @param event defines the drop event to use as source
  71121. */
  71122. loadFiles(event: any): void;
  71123. private _processReload;
  71124. /**
  71125. * Reload the current scene from the loaded files
  71126. */
  71127. reload(): void;
  71128. }
  71129. }
  71130. declare module BABYLON {
  71131. /**
  71132. * Defines the root class used to create scene optimization to use with SceneOptimizer
  71133. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71134. */
  71135. export class SceneOptimization {
  71136. /**
  71137. * Defines the priority of this optimization (0 by default which means first in the list)
  71138. */
  71139. priority: number;
  71140. /**
  71141. * Gets a string describing the action executed by the current optimization
  71142. * @returns description string
  71143. */
  71144. getDescription(): string;
  71145. /**
  71146. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71147. * @param scene defines the current scene where to apply this optimization
  71148. * @param optimizer defines the current optimizer
  71149. * @returns true if everything that can be done was applied
  71150. */
  71151. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71152. /**
  71153. * Creates the SceneOptimization object
  71154. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71155. * @param desc defines the description associated with the optimization
  71156. */
  71157. constructor(
  71158. /**
  71159. * Defines the priority of this optimization (0 by default which means first in the list)
  71160. */
  71161. priority?: number);
  71162. }
  71163. /**
  71164. * Defines an optimization used to reduce the size of render target textures
  71165. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71166. */
  71167. export class TextureOptimization extends SceneOptimization {
  71168. /**
  71169. * Defines the priority of this optimization (0 by default which means first in the list)
  71170. */
  71171. priority: number;
  71172. /**
  71173. * 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
  71174. */
  71175. maximumSize: number;
  71176. /**
  71177. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71178. */
  71179. step: number;
  71180. /**
  71181. * Gets a string describing the action executed by the current optimization
  71182. * @returns description string
  71183. */
  71184. getDescription(): string;
  71185. /**
  71186. * Creates the TextureOptimization object
  71187. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71188. * @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
  71189. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71190. */
  71191. constructor(
  71192. /**
  71193. * Defines the priority of this optimization (0 by default which means first in the list)
  71194. */
  71195. priority?: number,
  71196. /**
  71197. * 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
  71198. */
  71199. maximumSize?: number,
  71200. /**
  71201. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71202. */
  71203. step?: number);
  71204. /**
  71205. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71206. * @param scene defines the current scene where to apply this optimization
  71207. * @param optimizer defines the current optimizer
  71208. * @returns true if everything that can be done was applied
  71209. */
  71210. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71211. }
  71212. /**
  71213. * Defines an optimization used to increase or decrease the rendering resolution
  71214. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71215. */
  71216. export class HardwareScalingOptimization extends SceneOptimization {
  71217. /**
  71218. * Defines the priority of this optimization (0 by default which means first in the list)
  71219. */
  71220. priority: number;
  71221. /**
  71222. * Defines the maximum scale to use (2 by default)
  71223. */
  71224. maximumScale: number;
  71225. /**
  71226. * Defines the step to use between two passes (0.5 by default)
  71227. */
  71228. step: number;
  71229. private _currentScale;
  71230. private _directionOffset;
  71231. /**
  71232. * Gets a string describing the action executed by the current optimization
  71233. * @return description string
  71234. */
  71235. getDescription(): string;
  71236. /**
  71237. * Creates the HardwareScalingOptimization object
  71238. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71239. * @param maximumScale defines the maximum scale to use (2 by default)
  71240. * @param step defines the step to use between two passes (0.5 by default)
  71241. */
  71242. constructor(
  71243. /**
  71244. * Defines the priority of this optimization (0 by default which means first in the list)
  71245. */
  71246. priority?: number,
  71247. /**
  71248. * Defines the maximum scale to use (2 by default)
  71249. */
  71250. maximumScale?: number,
  71251. /**
  71252. * Defines the step to use between two passes (0.5 by default)
  71253. */
  71254. step?: number);
  71255. /**
  71256. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71257. * @param scene defines the current scene where to apply this optimization
  71258. * @param optimizer defines the current optimizer
  71259. * @returns true if everything that can be done was applied
  71260. */
  71261. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71262. }
  71263. /**
  71264. * Defines an optimization used to remove shadows
  71265. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71266. */
  71267. export class ShadowsOptimization extends SceneOptimization {
  71268. /**
  71269. * Gets a string describing the action executed by the current optimization
  71270. * @return description string
  71271. */
  71272. getDescription(): string;
  71273. /**
  71274. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71275. * @param scene defines the current scene where to apply this optimization
  71276. * @param optimizer defines the current optimizer
  71277. * @returns true if everything that can be done was applied
  71278. */
  71279. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71280. }
  71281. /**
  71282. * Defines an optimization used to turn post-processes off
  71283. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71284. */
  71285. export class PostProcessesOptimization extends SceneOptimization {
  71286. /**
  71287. * Gets a string describing the action executed by the current optimization
  71288. * @return description string
  71289. */
  71290. getDescription(): string;
  71291. /**
  71292. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71293. * @param scene defines the current scene where to apply this optimization
  71294. * @param optimizer defines the current optimizer
  71295. * @returns true if everything that can be done was applied
  71296. */
  71297. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71298. }
  71299. /**
  71300. * Defines an optimization used to turn lens flares off
  71301. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71302. */
  71303. export class LensFlaresOptimization extends SceneOptimization {
  71304. /**
  71305. * Gets a string describing the action executed by the current optimization
  71306. * @return description string
  71307. */
  71308. getDescription(): string;
  71309. /**
  71310. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71311. * @param scene defines the current scene where to apply this optimization
  71312. * @param optimizer defines the current optimizer
  71313. * @returns true if everything that can be done was applied
  71314. */
  71315. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71316. }
  71317. /**
  71318. * Defines an optimization based on user defined callback.
  71319. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71320. */
  71321. export class CustomOptimization extends SceneOptimization {
  71322. /**
  71323. * Callback called to apply the custom optimization.
  71324. */
  71325. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  71326. /**
  71327. * Callback called to get custom description
  71328. */
  71329. onGetDescription: () => string;
  71330. /**
  71331. * Gets a string describing the action executed by the current optimization
  71332. * @returns description string
  71333. */
  71334. getDescription(): string;
  71335. /**
  71336. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71337. * @param scene defines the current scene where to apply this optimization
  71338. * @param optimizer defines the current optimizer
  71339. * @returns true if everything that can be done was applied
  71340. */
  71341. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71342. }
  71343. /**
  71344. * Defines an optimization used to turn particles off
  71345. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71346. */
  71347. export class ParticlesOptimization extends SceneOptimization {
  71348. /**
  71349. * Gets a string describing the action executed by the current optimization
  71350. * @return description string
  71351. */
  71352. getDescription(): string;
  71353. /**
  71354. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71355. * @param scene defines the current scene where to apply this optimization
  71356. * @param optimizer defines the current optimizer
  71357. * @returns true if everything that can be done was applied
  71358. */
  71359. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71360. }
  71361. /**
  71362. * Defines an optimization used to turn render targets off
  71363. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71364. */
  71365. export class RenderTargetsOptimization extends SceneOptimization {
  71366. /**
  71367. * Gets a string describing the action executed by the current optimization
  71368. * @return description string
  71369. */
  71370. getDescription(): string;
  71371. /**
  71372. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71373. * @param scene defines the current scene where to apply this optimization
  71374. * @param optimizer defines the current optimizer
  71375. * @returns true if everything that can be done was applied
  71376. */
  71377. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71378. }
  71379. /**
  71380. * Defines an optimization used to merge meshes with compatible materials
  71381. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71382. */
  71383. export class MergeMeshesOptimization extends SceneOptimization {
  71384. private static _UpdateSelectionTree;
  71385. /**
  71386. * Gets or sets a boolean which defines if optimization octree has to be updated
  71387. */
  71388. static get UpdateSelectionTree(): boolean;
  71389. /**
  71390. * Gets or sets a boolean which defines if optimization octree has to be updated
  71391. */
  71392. static set UpdateSelectionTree(value: boolean);
  71393. /**
  71394. * Gets a string describing the action executed by the current optimization
  71395. * @return description string
  71396. */
  71397. getDescription(): string;
  71398. private _canBeMerged;
  71399. /**
  71400. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71401. * @param scene defines the current scene where to apply this optimization
  71402. * @param optimizer defines the current optimizer
  71403. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  71404. * @returns true if everything that can be done was applied
  71405. */
  71406. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  71407. }
  71408. /**
  71409. * Defines a list of options used by SceneOptimizer
  71410. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71411. */
  71412. export class SceneOptimizerOptions {
  71413. /**
  71414. * Defines the target frame rate to reach (60 by default)
  71415. */
  71416. targetFrameRate: number;
  71417. /**
  71418. * Defines the interval between two checkes (2000ms by default)
  71419. */
  71420. trackerDuration: number;
  71421. /**
  71422. * Gets the list of optimizations to apply
  71423. */
  71424. optimizations: SceneOptimization[];
  71425. /**
  71426. * Creates a new list of options used by SceneOptimizer
  71427. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  71428. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  71429. */
  71430. constructor(
  71431. /**
  71432. * Defines the target frame rate to reach (60 by default)
  71433. */
  71434. targetFrameRate?: number,
  71435. /**
  71436. * Defines the interval between two checkes (2000ms by default)
  71437. */
  71438. trackerDuration?: number);
  71439. /**
  71440. * Add a new optimization
  71441. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  71442. * @returns the current SceneOptimizerOptions
  71443. */
  71444. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  71445. /**
  71446. * Add a new custom optimization
  71447. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  71448. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  71449. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71450. * @returns the current SceneOptimizerOptions
  71451. */
  71452. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  71453. /**
  71454. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  71455. * @param targetFrameRate defines the target frame rate (60 by default)
  71456. * @returns a SceneOptimizerOptions object
  71457. */
  71458. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71459. /**
  71460. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  71461. * @param targetFrameRate defines the target frame rate (60 by default)
  71462. * @returns a SceneOptimizerOptions object
  71463. */
  71464. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71465. /**
  71466. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  71467. * @param targetFrameRate defines the target frame rate (60 by default)
  71468. * @returns a SceneOptimizerOptions object
  71469. */
  71470. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71471. }
  71472. /**
  71473. * Class used to run optimizations in order to reach a target frame rate
  71474. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71475. */
  71476. export class SceneOptimizer implements IDisposable {
  71477. private _isRunning;
  71478. private _options;
  71479. private _scene;
  71480. private _currentPriorityLevel;
  71481. private _targetFrameRate;
  71482. private _trackerDuration;
  71483. private _currentFrameRate;
  71484. private _sceneDisposeObserver;
  71485. private _improvementMode;
  71486. /**
  71487. * Defines an observable called when the optimizer reaches the target frame rate
  71488. */
  71489. onSuccessObservable: Observable<SceneOptimizer>;
  71490. /**
  71491. * Defines an observable called when the optimizer enables an optimization
  71492. */
  71493. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  71494. /**
  71495. * Defines an observable called when the optimizer is not able to reach the target frame rate
  71496. */
  71497. onFailureObservable: Observable<SceneOptimizer>;
  71498. /**
  71499. * Gets a boolean indicating if the optimizer is in improvement mode
  71500. */
  71501. get isInImprovementMode(): boolean;
  71502. /**
  71503. * Gets the current priority level (0 at start)
  71504. */
  71505. get currentPriorityLevel(): number;
  71506. /**
  71507. * Gets the current frame rate checked by the SceneOptimizer
  71508. */
  71509. get currentFrameRate(): number;
  71510. /**
  71511. * Gets or sets the current target frame rate (60 by default)
  71512. */
  71513. get targetFrameRate(): number;
  71514. /**
  71515. * Gets or sets the current target frame rate (60 by default)
  71516. */
  71517. set targetFrameRate(value: number);
  71518. /**
  71519. * Gets or sets the current interval between two checks (every 2000ms by default)
  71520. */
  71521. get trackerDuration(): number;
  71522. /**
  71523. * Gets or sets the current interval between two checks (every 2000ms by default)
  71524. */
  71525. set trackerDuration(value: number);
  71526. /**
  71527. * Gets the list of active optimizations
  71528. */
  71529. get optimizations(): SceneOptimization[];
  71530. /**
  71531. * Creates a new SceneOptimizer
  71532. * @param scene defines the scene to work on
  71533. * @param options defines the options to use with the SceneOptimizer
  71534. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  71535. * @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)
  71536. */
  71537. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  71538. /**
  71539. * Stops the current optimizer
  71540. */
  71541. stop(): void;
  71542. /**
  71543. * Reset the optimizer to initial step (current priority level = 0)
  71544. */
  71545. reset(): void;
  71546. /**
  71547. * Start the optimizer. By default it will try to reach a specific framerate
  71548. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  71549. */
  71550. start(): void;
  71551. private _checkCurrentState;
  71552. /**
  71553. * Release all resources
  71554. */
  71555. dispose(): void;
  71556. /**
  71557. * Helper function to create a SceneOptimizer with one single line of code
  71558. * @param scene defines the scene to work on
  71559. * @param options defines the options to use with the SceneOptimizer
  71560. * @param onSuccess defines a callback to call on success
  71561. * @param onFailure defines a callback to call on failure
  71562. * @returns the new SceneOptimizer object
  71563. */
  71564. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  71565. }
  71566. }
  71567. declare module BABYLON {
  71568. /**
  71569. * Class used to serialize a scene into a string
  71570. */
  71571. export class SceneSerializer {
  71572. /**
  71573. * Clear cache used by a previous serialization
  71574. */
  71575. static ClearCache(): void;
  71576. /**
  71577. * Serialize a scene into a JSON compatible object
  71578. * @param scene defines the scene to serialize
  71579. * @returns a JSON compatible object
  71580. */
  71581. static Serialize(scene: Scene): any;
  71582. /**
  71583. * Serialize a mesh into a JSON compatible object
  71584. * @param toSerialize defines the mesh to serialize
  71585. * @param withParents defines if parents must be serialized as well
  71586. * @param withChildren defines if children must be serialized as well
  71587. * @returns a JSON compatible object
  71588. */
  71589. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  71590. }
  71591. }
  71592. declare module BABYLON {
  71593. /**
  71594. * Class used to host texture specific utilities
  71595. */
  71596. export class TextureTools {
  71597. /**
  71598. * Uses the GPU to create a copy texture rescaled at a given size
  71599. * @param texture Texture to copy from
  71600. * @param width defines the desired width
  71601. * @param height defines the desired height
  71602. * @param useBilinearMode defines if bilinear mode has to be used
  71603. * @return the generated texture
  71604. */
  71605. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  71606. }
  71607. }
  71608. declare module BABYLON {
  71609. /**
  71610. * This represents the different options available for the video capture.
  71611. */
  71612. export interface VideoRecorderOptions {
  71613. /** Defines the mime type of the video. */
  71614. mimeType: string;
  71615. /** Defines the FPS the video should be recorded at. */
  71616. fps: number;
  71617. /** Defines the chunk size for the recording data. */
  71618. recordChunckSize: number;
  71619. /** The audio tracks to attach to the recording. */
  71620. audioTracks?: MediaStreamTrack[];
  71621. }
  71622. /**
  71623. * This can help with recording videos from BabylonJS.
  71624. * This is based on the available WebRTC functionalities of the browser.
  71625. *
  71626. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  71627. */
  71628. export class VideoRecorder {
  71629. private static readonly _defaultOptions;
  71630. /**
  71631. * Returns whether or not the VideoRecorder is available in your browser.
  71632. * @param engine Defines the Babylon Engine.
  71633. * @returns true if supported otherwise false.
  71634. */
  71635. static IsSupported(engine: Engine): boolean;
  71636. private readonly _options;
  71637. private _canvas;
  71638. private _mediaRecorder;
  71639. private _recordedChunks;
  71640. private _fileName;
  71641. private _resolve;
  71642. private _reject;
  71643. /**
  71644. * True when a recording is already in progress.
  71645. */
  71646. get isRecording(): boolean;
  71647. /**
  71648. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  71649. * @param engine Defines the BabylonJS Engine you wish to record.
  71650. * @param options Defines options that can be used to customize the capture.
  71651. */
  71652. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  71653. /**
  71654. * Stops the current recording before the default capture timeout passed in the startRecording function.
  71655. */
  71656. stopRecording(): void;
  71657. /**
  71658. * Starts recording the canvas for a max duration specified in parameters.
  71659. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  71660. * If null no automatic download will start and you can rely on the promise to get the data back.
  71661. * @param maxDuration Defines the maximum recording time in seconds.
  71662. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  71663. * @return A promise callback at the end of the recording with the video data in Blob.
  71664. */
  71665. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  71666. /**
  71667. * Releases internal resources used during the recording.
  71668. */
  71669. dispose(): void;
  71670. private _handleDataAvailable;
  71671. private _handleError;
  71672. private _handleStop;
  71673. }
  71674. }
  71675. declare module BABYLON {
  71676. /**
  71677. * Class containing a set of static utilities functions for screenshots
  71678. */
  71679. export class ScreenshotTools {
  71680. /**
  71681. * Captures a screenshot of the current rendering
  71682. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71683. * @param engine defines the rendering engine
  71684. * @param camera defines the source camera
  71685. * @param size This parameter can be set to a single number or to an object with the
  71686. * following (optional) properties: precision, width, height. If a single number is passed,
  71687. * it will be used for both width and height. If an object is passed, the screenshot size
  71688. * will be derived from the parameters. The precision property is a multiplier allowing
  71689. * rendering at a higher or lower resolution
  71690. * @param successCallback defines the callback receives a single parameter which contains the
  71691. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  71692. * src parameter of an <img> to display it
  71693. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  71694. * Check your browser for supported MIME types
  71695. */
  71696. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  71697. /**
  71698. * Captures a screenshot of the current rendering
  71699. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71700. * @param engine defines the rendering engine
  71701. * @param camera defines the source camera
  71702. * @param size This parameter can be set to a single number or to an object with the
  71703. * following (optional) properties: precision, width, height. If a single number is passed,
  71704. * it will be used for both width and height. If an object is passed, the screenshot size
  71705. * will be derived from the parameters. The precision property is a multiplier allowing
  71706. * rendering at a higher or lower resolution
  71707. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  71708. * Check your browser for supported MIME types
  71709. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  71710. * to the src parameter of an <img> to display it
  71711. */
  71712. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  71713. /**
  71714. * Generates an image screenshot from the specified camera.
  71715. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71716. * @param engine The engine to use for rendering
  71717. * @param camera The camera to use for rendering
  71718. * @param size This parameter can be set to a single number or to an object with the
  71719. * following (optional) properties: precision, width, height. If a single number is passed,
  71720. * it will be used for both width and height. If an object is passed, the screenshot size
  71721. * will be derived from the parameters. The precision property is a multiplier allowing
  71722. * rendering at a higher or lower resolution
  71723. * @param successCallback The callback receives a single parameter which contains the
  71724. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  71725. * src parameter of an <img> to display it
  71726. * @param mimeType The MIME type of the screenshot image (default: image/png).
  71727. * Check your browser for supported MIME types
  71728. * @param samples Texture samples (default: 1)
  71729. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  71730. * @param fileName A name for for the downloaded file.
  71731. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  71732. */
  71733. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  71734. /**
  71735. * Generates an image screenshot from the specified camera.
  71736. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71737. * @param engine The engine to use for rendering
  71738. * @param camera The camera to use for rendering
  71739. * @param size This parameter can be set to a single number or to an object with the
  71740. * following (optional) properties: precision, width, height. If a single number is passed,
  71741. * it will be used for both width and height. If an object is passed, the screenshot size
  71742. * will be derived from the parameters. The precision property is a multiplier allowing
  71743. * rendering at a higher or lower resolution
  71744. * @param mimeType The MIME type of the screenshot image (default: image/png).
  71745. * Check your browser for supported MIME types
  71746. * @param samples Texture samples (default: 1)
  71747. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  71748. * @param fileName A name for for the downloaded file.
  71749. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  71750. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  71751. * to the src parameter of an <img> to display it
  71752. */
  71753. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  71754. /**
  71755. * Gets height and width for screenshot size
  71756. * @private
  71757. */
  71758. private static _getScreenshotSize;
  71759. }
  71760. }
  71761. declare module BABYLON {
  71762. /**
  71763. * Interface for a data buffer
  71764. */
  71765. export interface IDataBuffer {
  71766. /**
  71767. * Reads bytes from the data buffer.
  71768. * @param byteOffset The byte offset to read
  71769. * @param byteLength The byte length to read
  71770. * @returns A promise that resolves when the bytes are read
  71771. */
  71772. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  71773. /**
  71774. * The byte length of the buffer.
  71775. */
  71776. readonly byteLength: number;
  71777. }
  71778. /**
  71779. * Utility class for reading from a data buffer
  71780. */
  71781. export class DataReader {
  71782. /**
  71783. * The data buffer associated with this data reader.
  71784. */
  71785. readonly buffer: IDataBuffer;
  71786. /**
  71787. * The current byte offset from the beginning of the data buffer.
  71788. */
  71789. byteOffset: number;
  71790. private _dataView;
  71791. private _dataByteOffset;
  71792. /**
  71793. * Constructor
  71794. * @param buffer The buffer to read
  71795. */
  71796. constructor(buffer: IDataBuffer);
  71797. /**
  71798. * Loads the given byte length.
  71799. * @param byteLength The byte length to load
  71800. * @returns A promise that resolves when the load is complete
  71801. */
  71802. loadAsync(byteLength: number): Promise<void>;
  71803. /**
  71804. * Read a unsigned 32-bit integer from the currently loaded data range.
  71805. * @returns The 32-bit integer read
  71806. */
  71807. readUint32(): number;
  71808. /**
  71809. * Read a byte array from the currently loaded data range.
  71810. * @param byteLength The byte length to read
  71811. * @returns The byte array read
  71812. */
  71813. readUint8Array(byteLength: number): Uint8Array;
  71814. /**
  71815. * Read a string from the currently loaded data range.
  71816. * @param byteLength The byte length to read
  71817. * @returns The string read
  71818. */
  71819. readString(byteLength: number): string;
  71820. /**
  71821. * Skips the given byte length the currently loaded data range.
  71822. * @param byteLength The byte length to skip
  71823. */
  71824. skipBytes(byteLength: number): void;
  71825. }
  71826. }
  71827. declare module BABYLON {
  71828. /**
  71829. * Class for storing data to local storage if available or in-memory storage otherwise
  71830. */
  71831. export class DataStorage {
  71832. private static _Storage;
  71833. private static _GetStorage;
  71834. /**
  71835. * Reads a string from the data storage
  71836. * @param key The key to read
  71837. * @param defaultValue The value if the key doesn't exist
  71838. * @returns The string value
  71839. */
  71840. static ReadString(key: string, defaultValue: string): string;
  71841. /**
  71842. * Writes a string to the data storage
  71843. * @param key The key to write
  71844. * @param value The value to write
  71845. */
  71846. static WriteString(key: string, value: string): void;
  71847. /**
  71848. * Reads a boolean from the data storage
  71849. * @param key The key to read
  71850. * @param defaultValue The value if the key doesn't exist
  71851. * @returns The boolean value
  71852. */
  71853. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  71854. /**
  71855. * Writes a boolean to the data storage
  71856. * @param key The key to write
  71857. * @param value The value to write
  71858. */
  71859. static WriteBoolean(key: string, value: boolean): void;
  71860. /**
  71861. * Reads a number from the data storage
  71862. * @param key The key to read
  71863. * @param defaultValue The value if the key doesn't exist
  71864. * @returns The number value
  71865. */
  71866. static ReadNumber(key: string, defaultValue: number): number;
  71867. /**
  71868. * Writes a number to the data storage
  71869. * @param key The key to write
  71870. * @param value The value to write
  71871. */
  71872. static WriteNumber(key: string, value: number): void;
  71873. }
  71874. }
  71875. declare module BABYLON {
  71876. /**
  71877. * Options used for hit testing
  71878. */
  71879. export interface IWebXRLegacyHitTestOptions {
  71880. /**
  71881. * Only test when user interacted with the scene. Default - hit test every frame
  71882. */
  71883. testOnPointerDownOnly?: boolean;
  71884. /**
  71885. * The node to use to transform the local results to world coordinates
  71886. */
  71887. worldParentNode?: TransformNode;
  71888. }
  71889. /**
  71890. * Interface defining the babylon result of raycasting/hit-test
  71891. */
  71892. export interface IWebXRLegacyHitResult {
  71893. /**
  71894. * Transformation matrix that can be applied to a node that will put it in the hit point location
  71895. */
  71896. transformationMatrix: Matrix;
  71897. /**
  71898. * The native hit test result
  71899. */
  71900. xrHitResult: XRHitResult | XRHitTestResult;
  71901. }
  71902. /**
  71903. * The currently-working hit-test module.
  71904. * Hit test (or Ray-casting) is used to interact with the real world.
  71905. * For further information read here - https://github.com/immersive-web/hit-test
  71906. */
  71907. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  71908. /**
  71909. * options to use when constructing this feature
  71910. */
  71911. readonly options: IWebXRLegacyHitTestOptions;
  71912. private _direction;
  71913. private _mat;
  71914. private _onSelectEnabled;
  71915. private _origin;
  71916. /**
  71917. * The module's name
  71918. */
  71919. static readonly Name: string;
  71920. /**
  71921. * The (Babylon) version of this module.
  71922. * This is an integer representing the implementation version.
  71923. * This number does not correspond to the WebXR specs version
  71924. */
  71925. static readonly Version: number;
  71926. /**
  71927. * Populated with the last native XR Hit Results
  71928. */
  71929. lastNativeXRHitResults: XRHitResult[];
  71930. /**
  71931. * Triggered when new babylon (transformed) hit test results are available
  71932. */
  71933. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  71934. /**
  71935. * Creates a new instance of the (legacy version) hit test feature
  71936. * @param _xrSessionManager an instance of WebXRSessionManager
  71937. * @param options options to use when constructing this feature
  71938. */
  71939. constructor(_xrSessionManager: WebXRSessionManager,
  71940. /**
  71941. * options to use when constructing this feature
  71942. */
  71943. options?: IWebXRLegacyHitTestOptions);
  71944. /**
  71945. * execute a hit test with an XR Ray
  71946. *
  71947. * @param xrSession a native xrSession that will execute this hit test
  71948. * @param xrRay the ray (position and direction) to use for ray-casting
  71949. * @param referenceSpace native XR reference space to use for the hit-test
  71950. * @param filter filter function that will filter the results
  71951. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  71952. */
  71953. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  71954. /**
  71955. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  71956. * @param event the (select) event to use to select with
  71957. * @param referenceSpace the reference space to use for this hit test
  71958. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  71959. */
  71960. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  71961. /**
  71962. * attach this feature
  71963. * Will usually be called by the features manager
  71964. *
  71965. * @returns true if successful.
  71966. */
  71967. attach(): boolean;
  71968. /**
  71969. * detach this feature.
  71970. * Will usually be called by the features manager
  71971. *
  71972. * @returns true if successful.
  71973. */
  71974. detach(): boolean;
  71975. /**
  71976. * Dispose this feature and all of the resources attached
  71977. */
  71978. dispose(): void;
  71979. protected _onXRFrame(frame: XRFrame): void;
  71980. private _onHitTestResults;
  71981. private _onSelect;
  71982. }
  71983. }
  71984. declare module BABYLON {
  71985. /**
  71986. * Options used in the plane detector module
  71987. */
  71988. export interface IWebXRPlaneDetectorOptions {
  71989. /**
  71990. * The node to use to transform the local results to world coordinates
  71991. */
  71992. worldParentNode?: TransformNode;
  71993. }
  71994. /**
  71995. * A babylon interface for a WebXR plane.
  71996. * A Plane is actually a polygon, built from N points in space
  71997. *
  71998. * Supported in chrome 79, not supported in canary 81 ATM
  71999. */
  72000. export interface IWebXRPlane {
  72001. /**
  72002. * a babylon-assigned ID for this polygon
  72003. */
  72004. id: number;
  72005. /**
  72006. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  72007. */
  72008. polygonDefinition: Array<Vector3>;
  72009. /**
  72010. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  72011. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  72012. */
  72013. transformationMatrix: Matrix;
  72014. /**
  72015. * the native xr-plane object
  72016. */
  72017. xrPlane: XRPlane;
  72018. }
  72019. /**
  72020. * The plane detector is used to detect planes in the real world when in AR
  72021. * For more information see https://github.com/immersive-web/real-world-geometry/
  72022. */
  72023. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  72024. private _options;
  72025. private _detectedPlanes;
  72026. private _enabled;
  72027. private _lastFrameDetected;
  72028. /**
  72029. * The module's name
  72030. */
  72031. static readonly Name: string;
  72032. /**
  72033. * The (Babylon) version of this module.
  72034. * This is an integer representing the implementation version.
  72035. * This number does not correspond to the WebXR specs version
  72036. */
  72037. static readonly Version: number;
  72038. /**
  72039. * Observers registered here will be executed when a new plane was added to the session
  72040. */
  72041. onPlaneAddedObservable: Observable<IWebXRPlane>;
  72042. /**
  72043. * Observers registered here will be executed when a plane is no longer detected in the session
  72044. */
  72045. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  72046. /**
  72047. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  72048. * This can execute N times every frame
  72049. */
  72050. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  72051. /**
  72052. * construct a new Plane Detector
  72053. * @param _xrSessionManager an instance of xr Session manager
  72054. * @param _options configuration to use when constructing this feature
  72055. */
  72056. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  72057. /**
  72058. * Dispose this feature and all of the resources attached
  72059. */
  72060. dispose(): void;
  72061. protected _onXRFrame(frame: XRFrame): void;
  72062. private _init;
  72063. private _updatePlaneWithXRPlane;
  72064. /**
  72065. * avoiding using Array.find for global support.
  72066. * @param xrPlane the plane to find in the array
  72067. */
  72068. private findIndexInPlaneArray;
  72069. }
  72070. }
  72071. declare module BABYLON {
  72072. /**
  72073. * Configuration options of the anchor system
  72074. */
  72075. export interface IWebXRAnchorSystemOptions {
  72076. /**
  72077. * Should a new anchor be added every time a select event is triggered
  72078. */
  72079. addAnchorOnSelect?: boolean;
  72080. /**
  72081. * should the anchor system use plane detection.
  72082. * If set to true, the plane-detection feature should be set using setPlaneDetector
  72083. */
  72084. usePlaneDetection?: boolean;
  72085. /**
  72086. * a node that will be used to convert local to world coordinates
  72087. */
  72088. worldParentNode?: TransformNode;
  72089. }
  72090. /**
  72091. * A babylon container for an XR Anchor
  72092. */
  72093. export interface IWebXRAnchor {
  72094. /**
  72095. * A babylon-assigned ID for this anchor
  72096. */
  72097. id: number;
  72098. /**
  72099. * Transformation matrix to apply to an object attached to this anchor
  72100. */
  72101. transformationMatrix: Matrix;
  72102. /**
  72103. * The native anchor object
  72104. */
  72105. xrAnchor: XRAnchor;
  72106. }
  72107. /**
  72108. * An implementation of the anchor system of WebXR.
  72109. * Note that the current documented implementation is not available in any browser. Future implementations
  72110. * will use the frame to create an anchor and not the session or a detected plane
  72111. * For further information see https://github.com/immersive-web/anchors/
  72112. */
  72113. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  72114. private _options;
  72115. private _enabled;
  72116. private _hitTestModule;
  72117. private _lastFrameDetected;
  72118. private _onSelect;
  72119. private _planeDetector;
  72120. private _trackedAnchors;
  72121. /**
  72122. * The module's name
  72123. */
  72124. static readonly Name: string;
  72125. /**
  72126. * The (Babylon) version of this module.
  72127. * This is an integer representing the implementation version.
  72128. * This number does not correspond to the WebXR specs version
  72129. */
  72130. static readonly Version: number;
  72131. /**
  72132. * Observers registered here will be executed when a new anchor was added to the session
  72133. */
  72134. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  72135. /**
  72136. * Observers registered here will be executed when an anchor was removed from the session
  72137. */
  72138. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  72139. /**
  72140. * Observers registered here will be executed when an existing anchor updates
  72141. * This can execute N times every frame
  72142. */
  72143. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  72144. /**
  72145. * constructs a new anchor system
  72146. * @param _xrSessionManager an instance of WebXRSessionManager
  72147. * @param _options configuration object for this feature
  72148. */
  72149. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  72150. /**
  72151. * Add anchor at a specific XR point.
  72152. *
  72153. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  72154. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  72155. * @returns a promise the fulfills when the anchor was created
  72156. */
  72157. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  72158. /**
  72159. * attach this feature
  72160. * Will usually be called by the features manager
  72161. *
  72162. * @returns true if successful.
  72163. */
  72164. attach(): boolean;
  72165. /**
  72166. * detach this feature.
  72167. * Will usually be called by the features manager
  72168. *
  72169. * @returns true if successful.
  72170. */
  72171. detach(): boolean;
  72172. /**
  72173. * Dispose this feature and all of the resources attached
  72174. */
  72175. dispose(): void;
  72176. /**
  72177. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  72178. * @param hitTestModule the hit-test module to use.
  72179. */
  72180. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  72181. /**
  72182. * set the plane detector to use in order to create anchors from frames
  72183. * @param planeDetector the plane-detector module to use
  72184. * @param enable enable plane-anchors. default is true
  72185. */
  72186. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  72187. protected _onXRFrame(frame: XRFrame): void;
  72188. /**
  72189. * avoiding using Array.find for global support.
  72190. * @param xrAnchor the plane to find in the array
  72191. */
  72192. private _findIndexInAnchorArray;
  72193. private _updateAnchorWithXRFrame;
  72194. }
  72195. }
  72196. declare module BABYLON {
  72197. /**
  72198. * Options interface for the background remover plugin
  72199. */
  72200. export interface IWebXRBackgroundRemoverOptions {
  72201. /**
  72202. * Further background meshes to disable when entering AR
  72203. */
  72204. backgroundMeshes?: AbstractMesh[];
  72205. /**
  72206. * flags to configure the removal of the environment helper.
  72207. * If not set, the entire background will be removed. If set, flags should be set as well.
  72208. */
  72209. environmentHelperRemovalFlags?: {
  72210. /**
  72211. * Should the skybox be removed (default false)
  72212. */
  72213. skyBox?: boolean;
  72214. /**
  72215. * Should the ground be removed (default false)
  72216. */
  72217. ground?: boolean;
  72218. };
  72219. /**
  72220. * don't disable the environment helper
  72221. */
  72222. ignoreEnvironmentHelper?: boolean;
  72223. }
  72224. /**
  72225. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  72226. */
  72227. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  72228. /**
  72229. * read-only options to be used in this module
  72230. */
  72231. readonly options: IWebXRBackgroundRemoverOptions;
  72232. /**
  72233. * The module's name
  72234. */
  72235. static readonly Name: string;
  72236. /**
  72237. * The (Babylon) version of this module.
  72238. * This is an integer representing the implementation version.
  72239. * This number does not correspond to the WebXR specs version
  72240. */
  72241. static readonly Version: number;
  72242. /**
  72243. * registered observers will be triggered when the background state changes
  72244. */
  72245. onBackgroundStateChangedObservable: Observable<boolean>;
  72246. /**
  72247. * constructs a new background remover module
  72248. * @param _xrSessionManager the session manager for this module
  72249. * @param options read-only options to be used in this module
  72250. */
  72251. constructor(_xrSessionManager: WebXRSessionManager,
  72252. /**
  72253. * read-only options to be used in this module
  72254. */
  72255. options?: IWebXRBackgroundRemoverOptions);
  72256. /**
  72257. * attach this feature
  72258. * Will usually be called by the features manager
  72259. *
  72260. * @returns true if successful.
  72261. */
  72262. attach(): boolean;
  72263. /**
  72264. * detach this feature.
  72265. * Will usually be called by the features manager
  72266. *
  72267. * @returns true if successful.
  72268. */
  72269. detach(): boolean;
  72270. /**
  72271. * Dispose this feature and all of the resources attached
  72272. */
  72273. dispose(): void;
  72274. protected _onXRFrame(_xrFrame: XRFrame): void;
  72275. private _setBackgroundState;
  72276. }
  72277. }
  72278. declare module BABYLON {
  72279. /**
  72280. * Options for the controller physics feature
  72281. */
  72282. export class IWebXRControllerPhysicsOptions {
  72283. /**
  72284. * Should the headset get its own impostor
  72285. */
  72286. enableHeadsetImpostor?: boolean;
  72287. /**
  72288. * Optional parameters for the headset impostor
  72289. */
  72290. headsetImpostorParams?: {
  72291. /**
  72292. * The type of impostor to create. Default is sphere
  72293. */
  72294. impostorType: number;
  72295. /**
  72296. * the size of the impostor. Defaults to 10cm
  72297. */
  72298. impostorSize?: number | {
  72299. width: number;
  72300. height: number;
  72301. depth: number;
  72302. };
  72303. /**
  72304. * Friction definitions
  72305. */
  72306. friction?: number;
  72307. /**
  72308. * Restitution
  72309. */
  72310. restitution?: number;
  72311. };
  72312. /**
  72313. * The physics properties of the future impostors
  72314. */
  72315. physicsProperties?: {
  72316. /**
  72317. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  72318. * Note that this requires a physics engine that supports mesh impostors!
  72319. */
  72320. useControllerMesh?: boolean;
  72321. /**
  72322. * The type of impostor to create. Default is sphere
  72323. */
  72324. impostorType?: number;
  72325. /**
  72326. * the size of the impostor. Defaults to 10cm
  72327. */
  72328. impostorSize?: number | {
  72329. width: number;
  72330. height: number;
  72331. depth: number;
  72332. };
  72333. /**
  72334. * Friction definitions
  72335. */
  72336. friction?: number;
  72337. /**
  72338. * Restitution
  72339. */
  72340. restitution?: number;
  72341. };
  72342. /**
  72343. * the xr input to use with this pointer selection
  72344. */
  72345. xrInput: WebXRInput;
  72346. }
  72347. /**
  72348. * Add physics impostor to your webxr controllers,
  72349. * including naive calculation of their linear and angular velocity
  72350. */
  72351. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  72352. private readonly _options;
  72353. private _attachController;
  72354. private _controllers;
  72355. private _debugMode;
  72356. private _delta;
  72357. private _headsetImpostor?;
  72358. private _headsetMesh?;
  72359. private _lastTimestamp;
  72360. private _tmpQuaternion;
  72361. private _tmpVector;
  72362. /**
  72363. * The module's name
  72364. */
  72365. static readonly Name: string;
  72366. /**
  72367. * The (Babylon) version of this module.
  72368. * This is an integer representing the implementation version.
  72369. * This number does not correspond to the webxr specs version
  72370. */
  72371. static readonly Version: number;
  72372. /**
  72373. * Construct a new Controller Physics Feature
  72374. * @param _xrSessionManager the corresponding xr session manager
  72375. * @param _options options to create this feature with
  72376. */
  72377. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  72378. /**
  72379. * @hidden
  72380. * enable debugging - will show console outputs and the impostor mesh
  72381. */
  72382. _enablePhysicsDebug(): void;
  72383. /**
  72384. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  72385. * @param xrController the controller to add
  72386. */
  72387. addController(xrController: WebXRInputSource): void;
  72388. /**
  72389. * attach this feature
  72390. * Will usually be called by the features manager
  72391. *
  72392. * @returns true if successful.
  72393. */
  72394. attach(): boolean;
  72395. /**
  72396. * detach this feature.
  72397. * Will usually be called by the features manager
  72398. *
  72399. * @returns true if successful.
  72400. */
  72401. detach(): boolean;
  72402. /**
  72403. * Get the headset impostor, if enabled
  72404. * @returns the impostor
  72405. */
  72406. getHeadsetImpostor(): PhysicsImpostor | undefined;
  72407. /**
  72408. * Get the physics impostor of a specific controller.
  72409. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  72410. * @param controller the controller or the controller id of which to get the impostor
  72411. * @returns the impostor or null
  72412. */
  72413. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  72414. /**
  72415. * Update the physics properties provided in the constructor
  72416. * @param newProperties the new properties object
  72417. */
  72418. setPhysicsProperties(newProperties: {
  72419. impostorType?: number;
  72420. impostorSize?: number | {
  72421. width: number;
  72422. height: number;
  72423. depth: number;
  72424. };
  72425. friction?: number;
  72426. restitution?: number;
  72427. }): void;
  72428. protected _onXRFrame(_xrFrame: any): void;
  72429. private _detachController;
  72430. }
  72431. }
  72432. declare module BABYLON {
  72433. /**
  72434. * Options used for hit testing (version 2)
  72435. */
  72436. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  72437. /**
  72438. * Do not create a permanent hit test. Will usually be used when only
  72439. * transient inputs are needed.
  72440. */
  72441. disablePermanentHitTest?: boolean;
  72442. /**
  72443. * Enable transient (for example touch-based) hit test inspections
  72444. */
  72445. enableTransientHitTest?: boolean;
  72446. /**
  72447. * Offset ray for the permanent hit test
  72448. */
  72449. offsetRay?: Vector3;
  72450. /**
  72451. * Offset ray for the transient hit test
  72452. */
  72453. transientOffsetRay?: Vector3;
  72454. /**
  72455. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  72456. */
  72457. useReferenceSpace?: boolean;
  72458. }
  72459. /**
  72460. * Interface defining the babylon result of hit-test
  72461. */
  72462. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  72463. /**
  72464. * The input source that generated this hit test (if transient)
  72465. */
  72466. inputSource?: XRInputSource;
  72467. /**
  72468. * Is this a transient hit test
  72469. */
  72470. isTransient?: boolean;
  72471. /**
  72472. * Position of the hit test result
  72473. */
  72474. position: Vector3;
  72475. /**
  72476. * Rotation of the hit test result
  72477. */
  72478. rotationQuaternion: Quaternion;
  72479. }
  72480. /**
  72481. * The currently-working hit-test module.
  72482. * Hit test (or Ray-casting) is used to interact with the real world.
  72483. * For further information read here - https://github.com/immersive-web/hit-test
  72484. *
  72485. * Tested on chrome (mobile) 80.
  72486. */
  72487. export class WebXRHitTest extends WebXRAbstractFeature {
  72488. /**
  72489. * options to use when constructing this feature
  72490. */
  72491. readonly options: IWebXRHitTestOptions;
  72492. private _tmpMat;
  72493. private _tmpPos;
  72494. private _tmpQuat;
  72495. private _transientXrHitTestSource;
  72496. private _xrHitTestSource;
  72497. private initHitTestSource;
  72498. /**
  72499. * The module's name
  72500. */
  72501. static readonly Name: string;
  72502. /**
  72503. * The (Babylon) version of this module.
  72504. * This is an integer representing the implementation version.
  72505. * This number does not correspond to the WebXR specs version
  72506. */
  72507. static readonly Version: number;
  72508. /**
  72509. * When set to true, each hit test will have its own position/rotation objects
  72510. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  72511. * the developers will clone them or copy them as they see fit.
  72512. */
  72513. autoCloneTransformation: boolean;
  72514. /**
  72515. * Populated with the last native XR Hit Results
  72516. */
  72517. lastNativeXRHitResults: XRHitResult[];
  72518. /**
  72519. * Triggered when new babylon (transformed) hit test results are available
  72520. */
  72521. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  72522. /**
  72523. * Use this to temporarily pause hit test checks.
  72524. */
  72525. paused: boolean;
  72526. /**
  72527. * Creates a new instance of the hit test feature
  72528. * @param _xrSessionManager an instance of WebXRSessionManager
  72529. * @param options options to use when constructing this feature
  72530. */
  72531. constructor(_xrSessionManager: WebXRSessionManager,
  72532. /**
  72533. * options to use when constructing this feature
  72534. */
  72535. options?: IWebXRHitTestOptions);
  72536. /**
  72537. * attach this feature
  72538. * Will usually be called by the features manager
  72539. *
  72540. * @returns true if successful.
  72541. */
  72542. attach(): boolean;
  72543. /**
  72544. * detach this feature.
  72545. * Will usually be called by the features manager
  72546. *
  72547. * @returns true if successful.
  72548. */
  72549. detach(): boolean;
  72550. /**
  72551. * Dispose this feature and all of the resources attached
  72552. */
  72553. dispose(): void;
  72554. protected _onXRFrame(frame: XRFrame): void;
  72555. private _processWebXRHitTestResult;
  72556. }
  72557. }
  72558. declare module BABYLON {
  72559. /**
  72560. * The motion controller class for all microsoft mixed reality controllers
  72561. */
  72562. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  72563. protected readonly _mapping: {
  72564. defaultButton: {
  72565. valueNodeName: string;
  72566. unpressedNodeName: string;
  72567. pressedNodeName: string;
  72568. };
  72569. defaultAxis: {
  72570. valueNodeName: string;
  72571. minNodeName: string;
  72572. maxNodeName: string;
  72573. };
  72574. buttons: {
  72575. "xr-standard-trigger": {
  72576. rootNodeName: string;
  72577. componentProperty: string;
  72578. states: string[];
  72579. };
  72580. "xr-standard-squeeze": {
  72581. rootNodeName: string;
  72582. componentProperty: string;
  72583. states: string[];
  72584. };
  72585. "xr-standard-touchpad": {
  72586. rootNodeName: string;
  72587. labelAnchorNodeName: string;
  72588. touchPointNodeName: string;
  72589. };
  72590. "xr-standard-thumbstick": {
  72591. rootNodeName: string;
  72592. componentProperty: string;
  72593. states: string[];
  72594. };
  72595. };
  72596. axes: {
  72597. "xr-standard-touchpad": {
  72598. "x-axis": {
  72599. rootNodeName: string;
  72600. };
  72601. "y-axis": {
  72602. rootNodeName: string;
  72603. };
  72604. };
  72605. "xr-standard-thumbstick": {
  72606. "x-axis": {
  72607. rootNodeName: string;
  72608. };
  72609. "y-axis": {
  72610. rootNodeName: string;
  72611. };
  72612. };
  72613. };
  72614. };
  72615. /**
  72616. * The base url used to load the left and right controller models
  72617. */
  72618. static MODEL_BASE_URL: string;
  72619. /**
  72620. * The name of the left controller model file
  72621. */
  72622. static MODEL_LEFT_FILENAME: string;
  72623. /**
  72624. * The name of the right controller model file
  72625. */
  72626. static MODEL_RIGHT_FILENAME: string;
  72627. profileId: string;
  72628. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  72629. protected _getFilenameAndPath(): {
  72630. filename: string;
  72631. path: string;
  72632. };
  72633. protected _getModelLoadingConstraints(): boolean;
  72634. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  72635. protected _setRootMesh(meshes: AbstractMesh[]): void;
  72636. protected _updateModel(): void;
  72637. }
  72638. }
  72639. declare module BABYLON {
  72640. /**
  72641. * The motion controller class for oculus touch (quest, rift).
  72642. * This class supports legacy mapping as well the standard xr mapping
  72643. */
  72644. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  72645. private _forceLegacyControllers;
  72646. private _modelRootNode;
  72647. /**
  72648. * The base url used to load the left and right controller models
  72649. */
  72650. static MODEL_BASE_URL: string;
  72651. /**
  72652. * The name of the left controller model file
  72653. */
  72654. static MODEL_LEFT_FILENAME: string;
  72655. /**
  72656. * The name of the right controller model file
  72657. */
  72658. static MODEL_RIGHT_FILENAME: string;
  72659. /**
  72660. * Base Url for the Quest controller model.
  72661. */
  72662. static QUEST_MODEL_BASE_URL: string;
  72663. profileId: string;
  72664. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  72665. protected _getFilenameAndPath(): {
  72666. filename: string;
  72667. path: string;
  72668. };
  72669. protected _getModelLoadingConstraints(): boolean;
  72670. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  72671. protected _setRootMesh(meshes: AbstractMesh[]): void;
  72672. protected _updateModel(): void;
  72673. /**
  72674. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  72675. * between the touch and touch 2.
  72676. */
  72677. private _isQuest;
  72678. }
  72679. }
  72680. declare module BABYLON {
  72681. /**
  72682. * The motion controller class for the standard HTC-Vive controllers
  72683. */
  72684. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  72685. private _modelRootNode;
  72686. /**
  72687. * The base url used to load the left and right controller models
  72688. */
  72689. static MODEL_BASE_URL: string;
  72690. /**
  72691. * File name for the controller model.
  72692. */
  72693. static MODEL_FILENAME: string;
  72694. profileId: string;
  72695. /**
  72696. * Create a new Vive motion controller object
  72697. * @param scene the scene to use to create this controller
  72698. * @param gamepadObject the corresponding gamepad object
  72699. * @param handedness the handedness of the controller
  72700. */
  72701. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  72702. protected _getFilenameAndPath(): {
  72703. filename: string;
  72704. path: string;
  72705. };
  72706. protected _getModelLoadingConstraints(): boolean;
  72707. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  72708. protected _setRootMesh(meshes: AbstractMesh[]): void;
  72709. protected _updateModel(): void;
  72710. }
  72711. }
  72712. declare module BABYLON {
  72713. /**
  72714. * A cursor which tracks a point on a path
  72715. */
  72716. export class PathCursor {
  72717. private path;
  72718. /**
  72719. * Stores path cursor callbacks for when an onchange event is triggered
  72720. */
  72721. private _onchange;
  72722. /**
  72723. * The value of the path cursor
  72724. */
  72725. value: number;
  72726. /**
  72727. * The animation array of the path cursor
  72728. */
  72729. animations: Animation[];
  72730. /**
  72731. * Initializes the path cursor
  72732. * @param path The path to track
  72733. */
  72734. constructor(path: Path2);
  72735. /**
  72736. * Gets the cursor point on the path
  72737. * @returns A point on the path cursor at the cursor location
  72738. */
  72739. getPoint(): Vector3;
  72740. /**
  72741. * Moves the cursor ahead by the step amount
  72742. * @param step The amount to move the cursor forward
  72743. * @returns This path cursor
  72744. */
  72745. moveAhead(step?: number): PathCursor;
  72746. /**
  72747. * Moves the cursor behind by the step amount
  72748. * @param step The amount to move the cursor back
  72749. * @returns This path cursor
  72750. */
  72751. moveBack(step?: number): PathCursor;
  72752. /**
  72753. * Moves the cursor by the step amount
  72754. * If the step amount is greater than one, an exception is thrown
  72755. * @param step The amount to move the cursor
  72756. * @returns This path cursor
  72757. */
  72758. move(step: number): PathCursor;
  72759. /**
  72760. * Ensures that the value is limited between zero and one
  72761. * @returns This path cursor
  72762. */
  72763. private ensureLimits;
  72764. /**
  72765. * Runs onchange callbacks on change (used by the animation engine)
  72766. * @returns This path cursor
  72767. */
  72768. private raiseOnChange;
  72769. /**
  72770. * Executes a function on change
  72771. * @param f A path cursor onchange callback
  72772. * @returns This path cursor
  72773. */
  72774. onchange(f: (cursor: PathCursor) => void): PathCursor;
  72775. }
  72776. }
  72777. declare module BABYLON {
  72778. /** @hidden */
  72779. export var blurPixelShader: {
  72780. name: string;
  72781. shader: string;
  72782. };
  72783. }
  72784. declare module BABYLON {
  72785. /** @hidden */
  72786. export var pointCloudVertexDeclaration: {
  72787. name: string;
  72788. shader: string;
  72789. };
  72790. }
  72791. // Mixins
  72792. interface Window {
  72793. mozIndexedDB: IDBFactory;
  72794. webkitIndexedDB: IDBFactory;
  72795. msIndexedDB: IDBFactory;
  72796. webkitURL: typeof URL;
  72797. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  72798. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  72799. WebGLRenderingContext: WebGLRenderingContext;
  72800. MSGesture: MSGesture;
  72801. CANNON: any;
  72802. AudioContext: AudioContext;
  72803. webkitAudioContext: AudioContext;
  72804. PointerEvent: any;
  72805. Math: Math;
  72806. Uint8Array: Uint8ArrayConstructor;
  72807. Float32Array: Float32ArrayConstructor;
  72808. mozURL: typeof URL;
  72809. msURL: typeof URL;
  72810. VRFrameData: any; // WebVR, from specs 1.1
  72811. DracoDecoderModule: any;
  72812. setImmediate(handler: (...args: any[]) => void): number;
  72813. }
  72814. interface HTMLCanvasElement {
  72815. requestPointerLock(): void;
  72816. msRequestPointerLock?(): void;
  72817. mozRequestPointerLock?(): void;
  72818. webkitRequestPointerLock?(): void;
  72819. /** Track wether a record is in progress */
  72820. isRecording: boolean;
  72821. /** Capture Stream method defined by some browsers */
  72822. captureStream(fps?: number): MediaStream;
  72823. }
  72824. interface CanvasRenderingContext2D {
  72825. msImageSmoothingEnabled: boolean;
  72826. }
  72827. interface MouseEvent {
  72828. mozMovementX: number;
  72829. mozMovementY: number;
  72830. webkitMovementX: number;
  72831. webkitMovementY: number;
  72832. msMovementX: number;
  72833. msMovementY: number;
  72834. }
  72835. interface Navigator {
  72836. mozGetVRDevices: (any: any) => any;
  72837. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  72838. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  72839. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  72840. webkitGetGamepads(): Gamepad[];
  72841. msGetGamepads(): Gamepad[];
  72842. webkitGamepads(): Gamepad[];
  72843. }
  72844. interface HTMLVideoElement {
  72845. mozSrcObject: any;
  72846. }
  72847. interface Math {
  72848. fround(x: number): number;
  72849. imul(a: number, b: number): number;
  72850. }
  72851. interface WebGLRenderingContext {
  72852. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  72853. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  72854. vertexAttribDivisor(index: number, divisor: number): void;
  72855. createVertexArray(): any;
  72856. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  72857. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  72858. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  72859. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  72860. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  72861. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  72862. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  72863. // Queries
  72864. createQuery(): WebGLQuery;
  72865. deleteQuery(query: WebGLQuery): void;
  72866. beginQuery(target: number, query: WebGLQuery): void;
  72867. endQuery(target: number): void;
  72868. getQueryParameter(query: WebGLQuery, pname: number): any;
  72869. getQuery(target: number, pname: number): any;
  72870. MAX_SAMPLES: number;
  72871. RGBA8: number;
  72872. READ_FRAMEBUFFER: number;
  72873. DRAW_FRAMEBUFFER: number;
  72874. UNIFORM_BUFFER: number;
  72875. HALF_FLOAT_OES: number;
  72876. RGBA16F: number;
  72877. RGBA32F: number;
  72878. R32F: number;
  72879. RG32F: number;
  72880. RGB32F: number;
  72881. R16F: number;
  72882. RG16F: number;
  72883. RGB16F: number;
  72884. RED: number;
  72885. RG: number;
  72886. R8: number;
  72887. RG8: number;
  72888. UNSIGNED_INT_24_8: number;
  72889. DEPTH24_STENCIL8: number;
  72890. MIN: number;
  72891. MAX: number;
  72892. /* Multiple Render Targets */
  72893. drawBuffers(buffers: number[]): void;
  72894. readBuffer(src: number): void;
  72895. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  72896. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  72897. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  72898. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  72899. // Occlusion Query
  72900. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  72901. ANY_SAMPLES_PASSED: number;
  72902. QUERY_RESULT_AVAILABLE: number;
  72903. QUERY_RESULT: number;
  72904. }
  72905. interface WebGLProgram {
  72906. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  72907. }
  72908. interface EXT_disjoint_timer_query {
  72909. QUERY_COUNTER_BITS_EXT: number;
  72910. TIME_ELAPSED_EXT: number;
  72911. TIMESTAMP_EXT: number;
  72912. GPU_DISJOINT_EXT: number;
  72913. QUERY_RESULT_EXT: number;
  72914. QUERY_RESULT_AVAILABLE_EXT: number;
  72915. queryCounterEXT(query: WebGLQuery, target: number): void;
  72916. createQueryEXT(): WebGLQuery;
  72917. beginQueryEXT(target: number, query: WebGLQuery): void;
  72918. endQueryEXT(target: number): void;
  72919. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  72920. deleteQueryEXT(query: WebGLQuery): void;
  72921. }
  72922. interface WebGLUniformLocation {
  72923. _currentState: any;
  72924. }
  72925. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  72926. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  72927. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  72928. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  72929. interface WebGLRenderingContext {
  72930. readonly RASTERIZER_DISCARD: number;
  72931. readonly DEPTH_COMPONENT24: number;
  72932. readonly TEXTURE_3D: number;
  72933. readonly TEXTURE_2D_ARRAY: number;
  72934. readonly TEXTURE_COMPARE_FUNC: number;
  72935. readonly TEXTURE_COMPARE_MODE: number;
  72936. readonly COMPARE_REF_TO_TEXTURE: number;
  72937. readonly TEXTURE_WRAP_R: number;
  72938. readonly HALF_FLOAT: number;
  72939. readonly RGB8: number;
  72940. readonly RED_INTEGER: number;
  72941. readonly RG_INTEGER: number;
  72942. readonly RGB_INTEGER: number;
  72943. readonly RGBA_INTEGER: number;
  72944. readonly R8_SNORM: number;
  72945. readonly RG8_SNORM: number;
  72946. readonly RGB8_SNORM: number;
  72947. readonly RGBA8_SNORM: number;
  72948. readonly R8I: number;
  72949. readonly RG8I: number;
  72950. readonly RGB8I: number;
  72951. readonly RGBA8I: number;
  72952. readonly R8UI: number;
  72953. readonly RG8UI: number;
  72954. readonly RGB8UI: number;
  72955. readonly RGBA8UI: number;
  72956. readonly R16I: number;
  72957. readonly RG16I: number;
  72958. readonly RGB16I: number;
  72959. readonly RGBA16I: number;
  72960. readonly R16UI: number;
  72961. readonly RG16UI: number;
  72962. readonly RGB16UI: number;
  72963. readonly RGBA16UI: number;
  72964. readonly R32I: number;
  72965. readonly RG32I: number;
  72966. readonly RGB32I: number;
  72967. readonly RGBA32I: number;
  72968. readonly R32UI: number;
  72969. readonly RG32UI: number;
  72970. readonly RGB32UI: number;
  72971. readonly RGBA32UI: number;
  72972. readonly RGB10_A2UI: number;
  72973. readonly R11F_G11F_B10F: number;
  72974. readonly RGB9_E5: number;
  72975. readonly RGB10_A2: number;
  72976. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  72977. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  72978. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  72979. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  72980. readonly DEPTH_COMPONENT32F: number;
  72981. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  72982. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  72983. 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;
  72984. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  72985. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  72986. readonly TRANSFORM_FEEDBACK: number;
  72987. readonly INTERLEAVED_ATTRIBS: number;
  72988. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  72989. createTransformFeedback(): WebGLTransformFeedback;
  72990. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  72991. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  72992. beginTransformFeedback(primitiveMode: number): void;
  72993. endTransformFeedback(): void;
  72994. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  72995. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  72996. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  72997. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  72998. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  72999. }
  73000. interface ImageBitmap {
  73001. readonly width: number;
  73002. readonly height: number;
  73003. close(): void;
  73004. }
  73005. interface WebGLQuery extends WebGLObject {
  73006. }
  73007. declare var WebGLQuery: {
  73008. prototype: WebGLQuery;
  73009. new(): WebGLQuery;
  73010. };
  73011. interface WebGLSampler extends WebGLObject {
  73012. }
  73013. declare var WebGLSampler: {
  73014. prototype: WebGLSampler;
  73015. new(): WebGLSampler;
  73016. };
  73017. interface WebGLSync extends WebGLObject {
  73018. }
  73019. declare var WebGLSync: {
  73020. prototype: WebGLSync;
  73021. new(): WebGLSync;
  73022. };
  73023. interface WebGLTransformFeedback extends WebGLObject {
  73024. }
  73025. declare var WebGLTransformFeedback: {
  73026. prototype: WebGLTransformFeedback;
  73027. new(): WebGLTransformFeedback;
  73028. };
  73029. interface WebGLVertexArrayObject extends WebGLObject {
  73030. }
  73031. declare var WebGLVertexArrayObject: {
  73032. prototype: WebGLVertexArrayObject;
  73033. new(): WebGLVertexArrayObject;
  73034. };
  73035. // Type definitions for WebVR API
  73036. // Project: https://w3c.github.io/webvr/
  73037. // Definitions by: six a <https://github.com/lostfictions>
  73038. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  73039. interface VRDisplay extends EventTarget {
  73040. /**
  73041. * Dictionary of capabilities describing the VRDisplay.
  73042. */
  73043. readonly capabilities: VRDisplayCapabilities;
  73044. /**
  73045. * z-depth defining the far plane of the eye view frustum
  73046. * enables mapping of values in the render target depth
  73047. * attachment to scene coordinates. Initially set to 10000.0.
  73048. */
  73049. depthFar: number;
  73050. /**
  73051. * z-depth defining the near plane of the eye view frustum
  73052. * enables mapping of values in the render target depth
  73053. * attachment to scene coordinates. Initially set to 0.01.
  73054. */
  73055. depthNear: number;
  73056. /**
  73057. * An identifier for this distinct VRDisplay. Used as an
  73058. * association point in the Gamepad API.
  73059. */
  73060. readonly displayId: number;
  73061. /**
  73062. * A display name, a user-readable name identifying it.
  73063. */
  73064. readonly displayName: string;
  73065. readonly isConnected: boolean;
  73066. readonly isPresenting: boolean;
  73067. /**
  73068. * If this VRDisplay supports room-scale experiences, the optional
  73069. * stage attribute contains details on the room-scale parameters.
  73070. */
  73071. readonly stageParameters: VRStageParameters | null;
  73072. /**
  73073. * Passing the value returned by `requestAnimationFrame` to
  73074. * `cancelAnimationFrame` will unregister the callback.
  73075. * @param handle Define the hanle of the request to cancel
  73076. */
  73077. cancelAnimationFrame(handle: number): void;
  73078. /**
  73079. * Stops presenting to the VRDisplay.
  73080. * @returns a promise to know when it stopped
  73081. */
  73082. exitPresent(): Promise<void>;
  73083. /**
  73084. * Return the current VREyeParameters for the given eye.
  73085. * @param whichEye Define the eye we want the parameter for
  73086. * @returns the eye parameters
  73087. */
  73088. getEyeParameters(whichEye: string): VREyeParameters;
  73089. /**
  73090. * Populates the passed VRFrameData with the information required to render
  73091. * the current frame.
  73092. * @param frameData Define the data structure to populate
  73093. * @returns true if ok otherwise false
  73094. */
  73095. getFrameData(frameData: VRFrameData): boolean;
  73096. /**
  73097. * Get the layers currently being presented.
  73098. * @returns the list of VR layers
  73099. */
  73100. getLayers(): VRLayer[];
  73101. /**
  73102. * Return a VRPose containing the future predicted pose of the VRDisplay
  73103. * when the current frame will be presented. The value returned will not
  73104. * change until JavaScript has returned control to the browser.
  73105. *
  73106. * The VRPose will contain the position, orientation, velocity,
  73107. * and acceleration of each of these properties.
  73108. * @returns the pose object
  73109. */
  73110. getPose(): VRPose;
  73111. /**
  73112. * Return the current instantaneous pose of the VRDisplay, with no
  73113. * prediction applied.
  73114. * @returns the current instantaneous pose
  73115. */
  73116. getImmediatePose(): VRPose;
  73117. /**
  73118. * The callback passed to `requestAnimationFrame` will be called
  73119. * any time a new frame should be rendered. When the VRDisplay is
  73120. * presenting the callback will be called at the native refresh
  73121. * rate of the HMD. When not presenting this function acts
  73122. * identically to how window.requestAnimationFrame acts. Content should
  73123. * make no assumptions of frame rate or vsync behavior as the HMD runs
  73124. * asynchronously from other displays and at differing refresh rates.
  73125. * @param callback Define the eaction to run next frame
  73126. * @returns the request handle it
  73127. */
  73128. requestAnimationFrame(callback: FrameRequestCallback): number;
  73129. /**
  73130. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  73131. * Repeat calls while already presenting will update the VRLayers being displayed.
  73132. * @param layers Define the list of layer to present
  73133. * @returns a promise to know when the request has been fulfilled
  73134. */
  73135. requestPresent(layers: VRLayer[]): Promise<void>;
  73136. /**
  73137. * Reset the pose for this display, treating its current position and
  73138. * orientation as the "origin/zero" values. VRPose.position,
  73139. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  73140. * updated when calling resetPose(). This should be called in only
  73141. * sitting-space experiences.
  73142. */
  73143. resetPose(): void;
  73144. /**
  73145. * The VRLayer provided to the VRDisplay will be captured and presented
  73146. * in the HMD. Calling this function has the same effect on the source
  73147. * canvas as any other operation that uses its source image, and canvases
  73148. * created without preserveDrawingBuffer set to true will be cleared.
  73149. * @param pose Define the pose to submit
  73150. */
  73151. submitFrame(pose?: VRPose): void;
  73152. }
  73153. declare var VRDisplay: {
  73154. prototype: VRDisplay;
  73155. new(): VRDisplay;
  73156. };
  73157. interface VRLayer {
  73158. leftBounds?: number[] | Float32Array | null;
  73159. rightBounds?: number[] | Float32Array | null;
  73160. source?: HTMLCanvasElement | null;
  73161. }
  73162. interface VRDisplayCapabilities {
  73163. readonly canPresent: boolean;
  73164. readonly hasExternalDisplay: boolean;
  73165. readonly hasOrientation: boolean;
  73166. readonly hasPosition: boolean;
  73167. readonly maxLayers: number;
  73168. }
  73169. interface VREyeParameters {
  73170. /** @deprecated */
  73171. readonly fieldOfView: VRFieldOfView;
  73172. readonly offset: Float32Array;
  73173. readonly renderHeight: number;
  73174. readonly renderWidth: number;
  73175. }
  73176. interface VRFieldOfView {
  73177. readonly downDegrees: number;
  73178. readonly leftDegrees: number;
  73179. readonly rightDegrees: number;
  73180. readonly upDegrees: number;
  73181. }
  73182. interface VRFrameData {
  73183. readonly leftProjectionMatrix: Float32Array;
  73184. readonly leftViewMatrix: Float32Array;
  73185. readonly pose: VRPose;
  73186. readonly rightProjectionMatrix: Float32Array;
  73187. readonly rightViewMatrix: Float32Array;
  73188. readonly timestamp: number;
  73189. }
  73190. interface VRPose {
  73191. readonly angularAcceleration: Float32Array | null;
  73192. readonly angularVelocity: Float32Array | null;
  73193. readonly linearAcceleration: Float32Array | null;
  73194. readonly linearVelocity: Float32Array | null;
  73195. readonly orientation: Float32Array | null;
  73196. readonly position: Float32Array | null;
  73197. readonly timestamp: number;
  73198. }
  73199. interface VRStageParameters {
  73200. sittingToStandingTransform?: Float32Array;
  73201. sizeX?: number;
  73202. sizeY?: number;
  73203. }
  73204. interface Navigator {
  73205. getVRDisplays(): Promise<VRDisplay[]>;
  73206. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  73207. }
  73208. interface Window {
  73209. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  73210. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  73211. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  73212. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  73213. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  73214. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  73215. }
  73216. interface Gamepad {
  73217. readonly displayId: number;
  73218. }
  73219. type XRSessionMode =
  73220. | "inline"
  73221. | "immersive-vr"
  73222. | "immersive-ar";
  73223. type XRReferenceSpaceType =
  73224. | "viewer"
  73225. | "local"
  73226. | "local-floor"
  73227. | "bounded-floor"
  73228. | "unbounded";
  73229. type XREnvironmentBlendMode =
  73230. | "opaque"
  73231. | "additive"
  73232. | "alpha-blend";
  73233. type XRVisibilityState =
  73234. | "visible"
  73235. | "visible-blurred"
  73236. | "hidden";
  73237. type XRHandedness =
  73238. | "none"
  73239. | "left"
  73240. | "right";
  73241. type XRTargetRayMode =
  73242. | "gaze"
  73243. | "tracked-pointer"
  73244. | "screen";
  73245. type XREye =
  73246. | "none"
  73247. | "left"
  73248. | "right";
  73249. type XREventType =
  73250. | "devicechange"
  73251. | "visibilitychange"
  73252. | "end"
  73253. | "inputsourceschange"
  73254. | "select"
  73255. | "selectstart"
  73256. | "selectend"
  73257. | "squeeze"
  73258. | "squeezestart"
  73259. | "squeezeend"
  73260. | "reset";
  73261. interface XRSpace extends EventTarget {
  73262. }
  73263. interface XRRenderState {
  73264. depthNear?: number;
  73265. depthFar?: number;
  73266. inlineVerticalFieldOfView?: number;
  73267. baseLayer?: XRWebGLLayer;
  73268. }
  73269. interface XRInputSource {
  73270. handedness: XRHandedness;
  73271. targetRayMode: XRTargetRayMode;
  73272. targetRaySpace: XRSpace;
  73273. gripSpace: XRSpace | undefined;
  73274. gamepad: Gamepad | undefined;
  73275. profiles: Array<string>;
  73276. }
  73277. interface XRSessionInit {
  73278. optionalFeatures?: string[];
  73279. requiredFeatures?: string[];
  73280. }
  73281. interface XRSession extends XRAnchorCreator {
  73282. addEventListener: Function;
  73283. removeEventListener: Function;
  73284. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  73285. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  73286. requestAnimationFrame: Function;
  73287. end(): Promise<void>;
  73288. renderState: XRRenderState;
  73289. inputSources: Array<XRInputSource>;
  73290. // hit test
  73291. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  73292. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  73293. // legacy AR hit test
  73294. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  73295. // legacy plane detection
  73296. updateWorldTrackingState(options: {
  73297. planeDetectionState?: { enabled: boolean; }
  73298. }): void;
  73299. }
  73300. interface XRReferenceSpace extends XRSpace {
  73301. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  73302. onreset: any;
  73303. }
  73304. type XRPlaneSet = Set<XRPlane>;
  73305. type XRAnchorSet = Set<XRAnchor>;
  73306. interface XRFrame {
  73307. session: XRSession;
  73308. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  73309. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  73310. // AR
  73311. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  73312. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  73313. // Anchors
  73314. trackedAnchors?: XRAnchorSet;
  73315. // Planes
  73316. worldInformation: {
  73317. detectedPlanes?: XRPlaneSet;
  73318. };
  73319. }
  73320. interface XRViewerPose extends XRPose {
  73321. views: Array<XRView>;
  73322. }
  73323. interface XRPose {
  73324. transform: XRRigidTransform;
  73325. emulatedPosition: boolean;
  73326. }
  73327. interface XRWebGLLayerOptions {
  73328. antialias?: boolean;
  73329. depth?: boolean;
  73330. stencil?: boolean;
  73331. alpha?: boolean;
  73332. multiview?: boolean;
  73333. framebufferScaleFactor?: number;
  73334. }
  73335. declare var XRWebGLLayer: {
  73336. prototype: XRWebGLLayer;
  73337. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  73338. };
  73339. interface XRWebGLLayer {
  73340. framebuffer: WebGLFramebuffer;
  73341. framebufferWidth: number;
  73342. framebufferHeight: number;
  73343. getViewport: Function;
  73344. }
  73345. declare class XRRigidTransform {
  73346. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  73347. position: DOMPointReadOnly;
  73348. orientation: DOMPointReadOnly;
  73349. matrix: Float32Array;
  73350. inverse: XRRigidTransform;
  73351. }
  73352. interface XRView {
  73353. eye: XREye;
  73354. projectionMatrix: Float32Array;
  73355. transform: XRRigidTransform;
  73356. }
  73357. interface XRInputSourceChangeEvent {
  73358. session: XRSession;
  73359. removed: Array<XRInputSource>;
  73360. added: Array<XRInputSource>;
  73361. }
  73362. interface XRInputSourceEvent extends Event {
  73363. readonly frame: XRFrame;
  73364. readonly inputSource: XRInputSource;
  73365. }
  73366. // Experimental(er) features
  73367. declare class XRRay {
  73368. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  73369. origin: DOMPointReadOnly;
  73370. direction: DOMPointReadOnly;
  73371. matrix: Float32Array;
  73372. }
  73373. declare enum XRHitTestTrackableType {
  73374. "point",
  73375. "plane"
  73376. }
  73377. interface XRHitResult {
  73378. hitMatrix: Float32Array;
  73379. }
  73380. interface XRTransientInputHitTestResult {
  73381. readonly inputSource: XRInputSource;
  73382. readonly results: Array<XRHitTestResult>;
  73383. }
  73384. interface XRHitTestResult {
  73385. getPose(baseSpace: XRSpace): XRPose | undefined;
  73386. }
  73387. interface XRHitTestSource {
  73388. cancel(): void;
  73389. }
  73390. interface XRTransientInputHitTestSource {
  73391. cancel(): void;
  73392. }
  73393. interface XRHitTestOptionsInit {
  73394. space: XRSpace;
  73395. entityTypes?: Array<XRHitTestTrackableType>;
  73396. offsetRay?: XRRay;
  73397. }
  73398. interface XRTransientInputHitTestOptionsInit {
  73399. profile: string;
  73400. entityTypes?: Array<XRHitTestTrackableType>;
  73401. offsetRay?: XRRay;
  73402. }
  73403. interface XRAnchor {
  73404. // remove?
  73405. id?: string;
  73406. anchorSpace: XRSpace;
  73407. lastChangedTime: number;
  73408. detach(): void;
  73409. }
  73410. interface XRPlane extends XRAnchorCreator {
  73411. orientation: "Horizontal" | "Vertical";
  73412. planeSpace: XRSpace;
  73413. polygon: Array<DOMPointReadOnly>;
  73414. lastChangedTime: number;
  73415. }
  73416. interface XRAnchorCreator {
  73417. // AR Anchors
  73418. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  73419. }
  73420. /**
  73421. * @ignore
  73422. */
  73423. declare module BABYLON.GLTF2.Exporter {
  73424. }
  73425. /**
  73426. * @ignore
  73427. */
  73428. declare module BABYLON.GLTF1 {
  73429. }
  73430. declare module BABYLON.GUI {
  73431. /**
  73432. * Class used to specific a value and its associated unit
  73433. */
  73434. export class ValueAndUnit {
  73435. /** defines the unit to store */
  73436. unit: number;
  73437. /** defines a boolean indicating if the value can be negative */
  73438. negativeValueAllowed: boolean;
  73439. private _value;
  73440. private _originalUnit;
  73441. /**
  73442. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  73443. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73444. */
  73445. ignoreAdaptiveScaling: boolean;
  73446. /**
  73447. * Creates a new ValueAndUnit
  73448. * @param value defines the value to store
  73449. * @param unit defines the unit to store
  73450. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  73451. */
  73452. constructor(value: number,
  73453. /** defines the unit to store */
  73454. unit?: number,
  73455. /** defines a boolean indicating if the value can be negative */
  73456. negativeValueAllowed?: boolean);
  73457. /** Gets a boolean indicating if the value is a percentage */
  73458. get isPercentage(): boolean;
  73459. /** Gets a boolean indicating if the value is store as pixel */
  73460. get isPixel(): boolean;
  73461. /** Gets direct internal value */
  73462. get internalValue(): number;
  73463. /**
  73464. * Gets value as pixel
  73465. * @param host defines the root host
  73466. * @param refValue defines the reference value for percentages
  73467. * @returns the value as pixel
  73468. */
  73469. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  73470. /**
  73471. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  73472. * @param value defines the value to store
  73473. * @param unit defines the unit to store
  73474. * @returns the current ValueAndUnit
  73475. */
  73476. updateInPlace(value: number, unit?: number): ValueAndUnit;
  73477. /**
  73478. * Gets the value accordingly to its unit
  73479. * @param host defines the root host
  73480. * @returns the value
  73481. */
  73482. getValue(host: AdvancedDynamicTexture): number;
  73483. /**
  73484. * Gets a string representation of the value
  73485. * @param host defines the root host
  73486. * @param decimals defines an optional number of decimals to display
  73487. * @returns a string
  73488. */
  73489. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  73490. /**
  73491. * Store a value parsed from a string
  73492. * @param source defines the source string
  73493. * @returns true if the value was successfully parsed
  73494. */
  73495. fromString(source: string | number): boolean;
  73496. private static _Regex;
  73497. private static _UNITMODE_PERCENTAGE;
  73498. private static _UNITMODE_PIXEL;
  73499. /** UNITMODE_PERCENTAGE */
  73500. static get UNITMODE_PERCENTAGE(): number;
  73501. /** UNITMODE_PIXEL */
  73502. static get UNITMODE_PIXEL(): number;
  73503. }
  73504. }
  73505. declare module BABYLON.GUI {
  73506. /**
  73507. * Define a style used by control to automatically setup properties based on a template.
  73508. * Only support font related properties so far
  73509. */
  73510. export class Style implements BABYLON.IDisposable {
  73511. private _fontFamily;
  73512. private _fontStyle;
  73513. private _fontWeight;
  73514. /** @hidden */
  73515. _host: AdvancedDynamicTexture;
  73516. /** @hidden */
  73517. _fontSize: ValueAndUnit;
  73518. /**
  73519. * BABYLON.Observable raised when the style values are changed
  73520. */
  73521. onChangedObservable: BABYLON.Observable<Style>;
  73522. /**
  73523. * Creates a new style object
  73524. * @param host defines the AdvancedDynamicTexture which hosts this style
  73525. */
  73526. constructor(host: AdvancedDynamicTexture);
  73527. /**
  73528. * Gets or sets the font size
  73529. */
  73530. get fontSize(): string | number;
  73531. set fontSize(value: string | number);
  73532. /**
  73533. * Gets or sets the font family
  73534. */
  73535. get fontFamily(): string;
  73536. set fontFamily(value: string);
  73537. /**
  73538. * Gets or sets the font style
  73539. */
  73540. get fontStyle(): string;
  73541. set fontStyle(value: string);
  73542. /** Gets or sets font weight */
  73543. get fontWeight(): string;
  73544. set fontWeight(value: string);
  73545. /** Dispose all associated resources */
  73546. dispose(): void;
  73547. }
  73548. }
  73549. declare module BABYLON.GUI {
  73550. /**
  73551. * Class used to transport BABYLON.Vector2 information for pointer events
  73552. */
  73553. export class Vector2WithInfo extends BABYLON.Vector2 {
  73554. /** defines the current mouse button index */
  73555. buttonIndex: number;
  73556. /**
  73557. * Creates a new Vector2WithInfo
  73558. * @param source defines the vector2 data to transport
  73559. * @param buttonIndex defines the current mouse button index
  73560. */
  73561. constructor(source: BABYLON.Vector2,
  73562. /** defines the current mouse button index */
  73563. buttonIndex?: number);
  73564. }
  73565. /** Class used to provide 2D matrix features */
  73566. export class Matrix2D {
  73567. /** Gets the internal array of 6 floats used to store matrix data */
  73568. m: Float32Array;
  73569. /**
  73570. * Creates a new matrix
  73571. * @param m00 defines value for (0, 0)
  73572. * @param m01 defines value for (0, 1)
  73573. * @param m10 defines value for (1, 0)
  73574. * @param m11 defines value for (1, 1)
  73575. * @param m20 defines value for (2, 0)
  73576. * @param m21 defines value for (2, 1)
  73577. */
  73578. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  73579. /**
  73580. * Fills the matrix from direct values
  73581. * @param m00 defines value for (0, 0)
  73582. * @param m01 defines value for (0, 1)
  73583. * @param m10 defines value for (1, 0)
  73584. * @param m11 defines value for (1, 1)
  73585. * @param m20 defines value for (2, 0)
  73586. * @param m21 defines value for (2, 1)
  73587. * @returns the current modified matrix
  73588. */
  73589. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  73590. /**
  73591. * Gets matrix determinant
  73592. * @returns the determinant
  73593. */
  73594. determinant(): number;
  73595. /**
  73596. * Inverses the matrix and stores it in a target matrix
  73597. * @param result defines the target matrix
  73598. * @returns the current matrix
  73599. */
  73600. invertToRef(result: Matrix2D): Matrix2D;
  73601. /**
  73602. * Multiplies the current matrix with another one
  73603. * @param other defines the second operand
  73604. * @param result defines the target matrix
  73605. * @returns the current matrix
  73606. */
  73607. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  73608. /**
  73609. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  73610. * @param x defines the x coordinate to transform
  73611. * @param y defines the x coordinate to transform
  73612. * @param result defines the target vector2
  73613. * @returns the current matrix
  73614. */
  73615. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  73616. /**
  73617. * Creates an identity matrix
  73618. * @returns a new matrix
  73619. */
  73620. static Identity(): Matrix2D;
  73621. /**
  73622. * Creates a translation matrix and stores it in a target matrix
  73623. * @param x defines the x coordinate of the translation
  73624. * @param y defines the y coordinate of the translation
  73625. * @param result defines the target matrix
  73626. */
  73627. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  73628. /**
  73629. * Creates a scaling matrix and stores it in a target matrix
  73630. * @param x defines the x coordinate of the scaling
  73631. * @param y defines the y coordinate of the scaling
  73632. * @param result defines the target matrix
  73633. */
  73634. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  73635. /**
  73636. * Creates a rotation matrix and stores it in a target matrix
  73637. * @param angle defines the rotation angle
  73638. * @param result defines the target matrix
  73639. */
  73640. static RotationToRef(angle: number, result: Matrix2D): void;
  73641. private static _TempPreTranslationMatrix;
  73642. private static _TempPostTranslationMatrix;
  73643. private static _TempRotationMatrix;
  73644. private static _TempScalingMatrix;
  73645. private static _TempCompose0;
  73646. private static _TempCompose1;
  73647. private static _TempCompose2;
  73648. /**
  73649. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  73650. * @param tx defines the x coordinate of the translation
  73651. * @param ty defines the y coordinate of the translation
  73652. * @param angle defines the rotation angle
  73653. * @param scaleX defines the x coordinate of the scaling
  73654. * @param scaleY defines the y coordinate of the scaling
  73655. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  73656. * @param result defines the target matrix
  73657. */
  73658. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  73659. }
  73660. }
  73661. declare module BABYLON.GUI {
  73662. /**
  73663. * Class used to store 2D control sizes
  73664. */
  73665. export class Measure {
  73666. /** defines left coordinate */
  73667. left: number;
  73668. /** defines top coordinate */
  73669. top: number;
  73670. /** defines width dimension */
  73671. width: number;
  73672. /** defines height dimension */
  73673. height: number;
  73674. /**
  73675. * Creates a new measure
  73676. * @param left defines left coordinate
  73677. * @param top defines top coordinate
  73678. * @param width defines width dimension
  73679. * @param height defines height dimension
  73680. */
  73681. constructor(
  73682. /** defines left coordinate */
  73683. left: number,
  73684. /** defines top coordinate */
  73685. top: number,
  73686. /** defines width dimension */
  73687. width: number,
  73688. /** defines height dimension */
  73689. height: number);
  73690. /**
  73691. * Copy from another measure
  73692. * @param other defines the other measure to copy from
  73693. */
  73694. copyFrom(other: Measure): void;
  73695. /**
  73696. * Copy from a group of 4 floats
  73697. * @param left defines left coordinate
  73698. * @param top defines top coordinate
  73699. * @param width defines width dimension
  73700. * @param height defines height dimension
  73701. */
  73702. copyFromFloats(left: number, top: number, width: number, height: number): void;
  73703. /**
  73704. * Computes the axis aligned bounding box measure for two given measures
  73705. * @param a Input measure
  73706. * @param b Input measure
  73707. * @param result the resulting bounding measure
  73708. */
  73709. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  73710. /**
  73711. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  73712. * @param transform the matrix to transform the measure before computing the AABB
  73713. * @param result the resulting AABB
  73714. */
  73715. transformToRef(transform: Matrix2D, result: Measure): void;
  73716. /**
  73717. * Check equality between this measure and another one
  73718. * @param other defines the other measures
  73719. * @returns true if both measures are equals
  73720. */
  73721. isEqualsTo(other: Measure): boolean;
  73722. /**
  73723. * Creates an empty measure
  73724. * @returns a new measure
  73725. */
  73726. static Empty(): Measure;
  73727. }
  73728. }
  73729. declare module BABYLON.GUI {
  73730. /**
  73731. * Interface used to define a control that can receive focus
  73732. */
  73733. export interface IFocusableControl {
  73734. /**
  73735. * Function called when the control receives the focus
  73736. */
  73737. onFocus(): void;
  73738. /**
  73739. * Function called when the control loses the focus
  73740. */
  73741. onBlur(): void;
  73742. /**
  73743. * Function called to let the control handle keyboard events
  73744. * @param evt defines the current keyboard event
  73745. */
  73746. processKeyboard(evt: KeyboardEvent): void;
  73747. /**
  73748. * Function called to get the list of controls that should not steal the focus from this control
  73749. * @returns an array of controls
  73750. */
  73751. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  73752. }
  73753. /**
  73754. * Class used to create texture to support 2D GUI elements
  73755. * @see http://doc.babylonjs.com/how_to/gui
  73756. */
  73757. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  73758. private _isDirty;
  73759. private _renderObserver;
  73760. private _resizeObserver;
  73761. private _preKeyboardObserver;
  73762. private _pointerMoveObserver;
  73763. private _pointerObserver;
  73764. private _canvasPointerOutObserver;
  73765. private _background;
  73766. /** @hidden */
  73767. _rootContainer: Container;
  73768. /** @hidden */
  73769. _lastPickedControl: Control;
  73770. /** @hidden */
  73771. _lastControlOver: {
  73772. [pointerId: number]: Control;
  73773. };
  73774. /** @hidden */
  73775. _lastControlDown: {
  73776. [pointerId: number]: Control;
  73777. };
  73778. /** @hidden */
  73779. _capturingControl: {
  73780. [pointerId: number]: Control;
  73781. };
  73782. /** @hidden */
  73783. _shouldBlockPointer: boolean;
  73784. /** @hidden */
  73785. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  73786. /** @hidden */
  73787. _linkedControls: Control[];
  73788. private _isFullscreen;
  73789. private _fullscreenViewport;
  73790. private _idealWidth;
  73791. private _idealHeight;
  73792. private _useSmallestIdeal;
  73793. private _renderAtIdealSize;
  73794. private _focusedControl;
  73795. private _blockNextFocusCheck;
  73796. private _renderScale;
  73797. private _rootElement;
  73798. private _cursorChanged;
  73799. private _defaultMousePointerId;
  73800. /** @hidden */
  73801. _numLayoutCalls: number;
  73802. /** Gets the number of layout calls made the last time the ADT has been rendered */
  73803. get numLayoutCalls(): number;
  73804. /** @hidden */
  73805. _numRenderCalls: number;
  73806. /** Gets the number of render calls made the last time the ADT has been rendered */
  73807. get numRenderCalls(): number;
  73808. /**
  73809. * Define type to string to ensure compatibility across browsers
  73810. * Safari doesn't support DataTransfer constructor
  73811. */
  73812. private _clipboardData;
  73813. /**
  73814. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  73815. */
  73816. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  73817. /**
  73818. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  73819. */
  73820. onControlPickedObservable: BABYLON.Observable<Control>;
  73821. /**
  73822. * BABYLON.Observable event triggered before layout is evaluated
  73823. */
  73824. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  73825. /**
  73826. * BABYLON.Observable event triggered after the layout was evaluated
  73827. */
  73828. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  73829. /**
  73830. * BABYLON.Observable event triggered before the texture is rendered
  73831. */
  73832. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  73833. /**
  73834. * BABYLON.Observable event triggered after the texture was rendered
  73835. */
  73836. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  73837. /**
  73838. * Gets or sets a boolean defining if alpha is stored as premultiplied
  73839. */
  73840. premulAlpha: boolean;
  73841. /**
  73842. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  73843. * Useful when you want more antialiasing
  73844. */
  73845. get renderScale(): number;
  73846. set renderScale(value: number);
  73847. /** Gets or sets the background color */
  73848. get background(): string;
  73849. set background(value: string);
  73850. /**
  73851. * Gets or sets the ideal width used to design controls.
  73852. * The GUI will then rescale everything accordingly
  73853. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73854. */
  73855. get idealWidth(): number;
  73856. set idealWidth(value: number);
  73857. /**
  73858. * Gets or sets the ideal height used to design controls.
  73859. * The GUI will then rescale everything accordingly
  73860. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73861. */
  73862. get idealHeight(): number;
  73863. set idealHeight(value: number);
  73864. /**
  73865. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  73866. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73867. */
  73868. get useSmallestIdeal(): boolean;
  73869. set useSmallestIdeal(value: boolean);
  73870. /**
  73871. * Gets or sets a boolean indicating if adaptive scaling must be used
  73872. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73873. */
  73874. get renderAtIdealSize(): boolean;
  73875. set renderAtIdealSize(value: boolean);
  73876. /**
  73877. * Gets the ratio used when in "ideal mode"
  73878. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73879. * */
  73880. get idealRatio(): number;
  73881. /**
  73882. * Gets the underlying layer used to render the texture when in fullscreen mode
  73883. */
  73884. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  73885. /**
  73886. * Gets the root container control
  73887. */
  73888. get rootContainer(): Container;
  73889. /**
  73890. * Returns an array containing the root container.
  73891. * This is mostly used to let the Inspector introspects the ADT
  73892. * @returns an array containing the rootContainer
  73893. */
  73894. getChildren(): Array<Container>;
  73895. /**
  73896. * Will return all controls that are inside this texture
  73897. * @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
  73898. * @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
  73899. * @return all child controls
  73900. */
  73901. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  73902. /**
  73903. * Gets or sets the current focused control
  73904. */
  73905. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  73906. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  73907. /**
  73908. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  73909. */
  73910. get isForeground(): boolean;
  73911. set isForeground(value: boolean);
  73912. /**
  73913. * Gets or set information about clipboardData
  73914. */
  73915. get clipboardData(): string;
  73916. set clipboardData(value: string);
  73917. /**
  73918. * Creates a new AdvancedDynamicTexture
  73919. * @param name defines the name of the texture
  73920. * @param width defines the width of the texture
  73921. * @param height defines the height of the texture
  73922. * @param scene defines the hosting scene
  73923. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  73924. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  73925. */
  73926. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  73927. /**
  73928. * Get the current class name of the texture useful for serialization or dynamic coding.
  73929. * @returns "AdvancedDynamicTexture"
  73930. */
  73931. getClassName(): string;
  73932. /**
  73933. * Function used to execute a function on all controls
  73934. * @param func defines the function to execute
  73935. * @param container defines the container where controls belong. If null the root container will be used
  73936. */
  73937. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  73938. private _useInvalidateRectOptimization;
  73939. /**
  73940. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  73941. */
  73942. get useInvalidateRectOptimization(): boolean;
  73943. set useInvalidateRectOptimization(value: boolean);
  73944. private _invalidatedRectangle;
  73945. /**
  73946. * Invalidates a rectangle area on the gui texture
  73947. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  73948. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  73949. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  73950. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  73951. */
  73952. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  73953. /**
  73954. * Marks the texture as dirty forcing a complete update
  73955. */
  73956. markAsDirty(): void;
  73957. /**
  73958. * Helper function used to create a new style
  73959. * @returns a new style
  73960. * @see http://doc.babylonjs.com/how_to/gui#styles
  73961. */
  73962. createStyle(): Style;
  73963. /**
  73964. * Adds a new control to the root container
  73965. * @param control defines the control to add
  73966. * @returns the current texture
  73967. */
  73968. addControl(control: Control): AdvancedDynamicTexture;
  73969. /**
  73970. * Removes a control from the root container
  73971. * @param control defines the control to remove
  73972. * @returns the current texture
  73973. */
  73974. removeControl(control: Control): AdvancedDynamicTexture;
  73975. /**
  73976. * Release all resources
  73977. */
  73978. dispose(): void;
  73979. private _onResize;
  73980. /** @hidden */
  73981. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  73982. /**
  73983. * Get screen coordinates for a vector3
  73984. * @param position defines the position to project
  73985. * @param worldMatrix defines the world matrix to use
  73986. * @returns the projected position
  73987. */
  73988. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  73989. private _checkUpdate;
  73990. private _clearMeasure;
  73991. private _render;
  73992. /** @hidden */
  73993. _changeCursor(cursor: string): void;
  73994. /** @hidden */
  73995. _registerLastControlDown(control: Control, pointerId: number): void;
  73996. private _doPicking;
  73997. /** @hidden */
  73998. _cleanControlAfterRemovalFromList(list: {
  73999. [pointerId: number]: Control;
  74000. }, control: Control): void;
  74001. /** @hidden */
  74002. _cleanControlAfterRemoval(control: Control): void;
  74003. /** Attach to all scene events required to support pointer events */
  74004. attach(): void;
  74005. /** @hidden */
  74006. private onClipboardCopy;
  74007. /** @hidden */
  74008. private onClipboardCut;
  74009. /** @hidden */
  74010. private onClipboardPaste;
  74011. /**
  74012. * Register the clipboard Events onto the canvas
  74013. */
  74014. registerClipboardEvents(): void;
  74015. /**
  74016. * Unregister the clipboard Events from the canvas
  74017. */
  74018. unRegisterClipboardEvents(): void;
  74019. /**
  74020. * Connect the texture to a hosting mesh to enable interactions
  74021. * @param mesh defines the mesh to attach to
  74022. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  74023. */
  74024. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  74025. /**
  74026. * Move the focus to a specific control
  74027. * @param control defines the control which will receive the focus
  74028. */
  74029. moveFocusToControl(control: IFocusableControl): void;
  74030. private _manageFocus;
  74031. private _attachToOnPointerOut;
  74032. /**
  74033. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  74034. * @param mesh defines the mesh which will receive the texture
  74035. * @param width defines the texture width (1024 by default)
  74036. * @param height defines the texture height (1024 by default)
  74037. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  74038. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  74039. * @returns a new AdvancedDynamicTexture
  74040. */
  74041. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  74042. /**
  74043. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  74044. * In this mode the texture will rely on a layer for its rendering.
  74045. * This allows it to be treated like any other layer.
  74046. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  74047. * LayerMask is set through advancedTexture.layer.layerMask
  74048. * @param name defines name for the texture
  74049. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  74050. * @param scene defines the hsoting scene
  74051. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  74052. * @returns a new AdvancedDynamicTexture
  74053. */
  74054. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  74055. }
  74056. }
  74057. declare module BABYLON.GUI {
  74058. /**
  74059. * Root class used for all 2D controls
  74060. * @see http://doc.babylonjs.com/how_to/gui#controls
  74061. */
  74062. export class Control {
  74063. /** defines the name of the control */
  74064. name?: string | undefined;
  74065. /**
  74066. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  74067. */
  74068. static AllowAlphaInheritance: boolean;
  74069. private _alpha;
  74070. private _alphaSet;
  74071. private _zIndex;
  74072. /** @hidden */
  74073. _host: AdvancedDynamicTexture;
  74074. /** Gets or sets the control parent */
  74075. parent: BABYLON.Nullable<Container>;
  74076. /** @hidden */
  74077. _currentMeasure: Measure;
  74078. private _fontFamily;
  74079. private _fontStyle;
  74080. private _fontWeight;
  74081. private _fontSize;
  74082. private _font;
  74083. /** @hidden */
  74084. _width: ValueAndUnit;
  74085. /** @hidden */
  74086. _height: ValueAndUnit;
  74087. /** @hidden */
  74088. protected _fontOffset: {
  74089. ascent: number;
  74090. height: number;
  74091. descent: number;
  74092. };
  74093. private _color;
  74094. private _style;
  74095. private _styleObserver;
  74096. /** @hidden */
  74097. protected _horizontalAlignment: number;
  74098. /** @hidden */
  74099. protected _verticalAlignment: number;
  74100. /** @hidden */
  74101. protected _isDirty: boolean;
  74102. /** @hidden */
  74103. protected _wasDirty: boolean;
  74104. /** @hidden */
  74105. _tempParentMeasure: Measure;
  74106. /** @hidden */
  74107. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  74108. /** @hidden */
  74109. protected _cachedParentMeasure: Measure;
  74110. private _paddingLeft;
  74111. private _paddingRight;
  74112. private _paddingTop;
  74113. private _paddingBottom;
  74114. /** @hidden */
  74115. _left: ValueAndUnit;
  74116. /** @hidden */
  74117. _top: ValueAndUnit;
  74118. private _scaleX;
  74119. private _scaleY;
  74120. private _rotation;
  74121. private _transformCenterX;
  74122. private _transformCenterY;
  74123. /** @hidden */
  74124. _transformMatrix: Matrix2D;
  74125. /** @hidden */
  74126. protected _invertTransformMatrix: Matrix2D;
  74127. /** @hidden */
  74128. protected _transformedPosition: BABYLON.Vector2;
  74129. private _isMatrixDirty;
  74130. private _cachedOffsetX;
  74131. private _cachedOffsetY;
  74132. private _isVisible;
  74133. private _isHighlighted;
  74134. /** @hidden */
  74135. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  74136. private _fontSet;
  74137. private _dummyVector2;
  74138. private _downCount;
  74139. private _enterCount;
  74140. private _doNotRender;
  74141. private _downPointerIds;
  74142. protected _isEnabled: boolean;
  74143. protected _disabledColor: string;
  74144. protected _disabledColorItem: string;
  74145. /** @hidden */
  74146. protected _rebuildLayout: boolean;
  74147. /** @hidden */
  74148. _customData: any;
  74149. /** @hidden */
  74150. _isClipped: boolean;
  74151. /** @hidden */
  74152. _automaticSize: boolean;
  74153. /** @hidden */
  74154. _tag: any;
  74155. /**
  74156. * 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
  74157. */
  74158. uniqueId: number;
  74159. /**
  74160. * Gets or sets an object used to store user defined information for the node
  74161. */
  74162. metadata: any;
  74163. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  74164. isHitTestVisible: boolean;
  74165. /** Gets or sets a boolean indicating if the control can block pointer events */
  74166. isPointerBlocker: boolean;
  74167. /** Gets or sets a boolean indicating if the control can be focusable */
  74168. isFocusInvisible: boolean;
  74169. /**
  74170. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  74171. * 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
  74172. */
  74173. clipChildren: boolean;
  74174. /**
  74175. * Gets or sets a boolean indicating that control content must be clipped
  74176. * 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
  74177. */
  74178. clipContent: boolean;
  74179. /**
  74180. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  74181. */
  74182. useBitmapCache: boolean;
  74183. private _cacheData;
  74184. private _shadowOffsetX;
  74185. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  74186. get shadowOffsetX(): number;
  74187. set shadowOffsetX(value: number);
  74188. private _shadowOffsetY;
  74189. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  74190. get shadowOffsetY(): number;
  74191. set shadowOffsetY(value: number);
  74192. private _shadowBlur;
  74193. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  74194. get shadowBlur(): number;
  74195. set shadowBlur(value: number);
  74196. private _shadowColor;
  74197. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  74198. get shadowColor(): string;
  74199. set shadowColor(value: string);
  74200. /** Gets or sets the cursor to use when the control is hovered */
  74201. hoverCursor: string;
  74202. /** @hidden */
  74203. protected _linkOffsetX: ValueAndUnit;
  74204. /** @hidden */
  74205. protected _linkOffsetY: ValueAndUnit;
  74206. /** Gets the control type name */
  74207. get typeName(): string;
  74208. /**
  74209. * Get the current class name of the control.
  74210. * @returns current class name
  74211. */
  74212. getClassName(): string;
  74213. /**
  74214. * An event triggered when pointer wheel is scrolled
  74215. */
  74216. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  74217. /**
  74218. * An event triggered when the pointer move over the control.
  74219. */
  74220. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  74221. /**
  74222. * An event triggered when the pointer move out of the control.
  74223. */
  74224. onPointerOutObservable: BABYLON.Observable<Control>;
  74225. /**
  74226. * An event triggered when the pointer taps the control
  74227. */
  74228. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  74229. /**
  74230. * An event triggered when pointer up
  74231. */
  74232. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  74233. /**
  74234. * An event triggered when a control is clicked on
  74235. */
  74236. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  74237. /**
  74238. * An event triggered when pointer enters the control
  74239. */
  74240. onPointerEnterObservable: BABYLON.Observable<Control>;
  74241. /**
  74242. * An event triggered when the control is marked as dirty
  74243. */
  74244. onDirtyObservable: BABYLON.Observable<Control>;
  74245. /**
  74246. * An event triggered before drawing the control
  74247. */
  74248. onBeforeDrawObservable: BABYLON.Observable<Control>;
  74249. /**
  74250. * An event triggered after the control was drawn
  74251. */
  74252. onAfterDrawObservable: BABYLON.Observable<Control>;
  74253. /**
  74254. * An event triggered when the control has been disposed
  74255. */
  74256. onDisposeObservable: BABYLON.Observable<Control>;
  74257. /**
  74258. * Get the hosting AdvancedDynamicTexture
  74259. */
  74260. get host(): AdvancedDynamicTexture;
  74261. /** Gets or set information about font offsets (used to render and align text) */
  74262. get fontOffset(): {
  74263. ascent: number;
  74264. height: number;
  74265. descent: number;
  74266. };
  74267. set fontOffset(offset: {
  74268. ascent: number;
  74269. height: number;
  74270. descent: number;
  74271. });
  74272. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  74273. get alpha(): number;
  74274. set alpha(value: number);
  74275. /**
  74276. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  74277. */
  74278. get isHighlighted(): boolean;
  74279. set isHighlighted(value: boolean);
  74280. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  74281. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74282. */
  74283. get scaleX(): number;
  74284. set scaleX(value: number);
  74285. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  74286. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74287. */
  74288. get scaleY(): number;
  74289. set scaleY(value: number);
  74290. /** Gets or sets the rotation angle (0 by default)
  74291. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74292. */
  74293. get rotation(): number;
  74294. set rotation(value: number);
  74295. /** Gets or sets the transformation center on Y axis (0 by default)
  74296. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74297. */
  74298. get transformCenterY(): number;
  74299. set transformCenterY(value: number);
  74300. /** Gets or sets the transformation center on X axis (0 by default)
  74301. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74302. */
  74303. get transformCenterX(): number;
  74304. set transformCenterX(value: number);
  74305. /**
  74306. * Gets or sets the horizontal alignment
  74307. * @see http://doc.babylonjs.com/how_to/gui#alignments
  74308. */
  74309. get horizontalAlignment(): number;
  74310. set horizontalAlignment(value: number);
  74311. /**
  74312. * Gets or sets the vertical alignment
  74313. * @see http://doc.babylonjs.com/how_to/gui#alignments
  74314. */
  74315. get verticalAlignment(): number;
  74316. set verticalAlignment(value: number);
  74317. /**
  74318. * Gets or sets control width
  74319. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74320. */
  74321. get width(): string | number;
  74322. set width(value: string | number);
  74323. /**
  74324. * Gets or sets the control width in pixel
  74325. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74326. */
  74327. get widthInPixels(): number;
  74328. set widthInPixels(value: number);
  74329. /**
  74330. * Gets or sets control height
  74331. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74332. */
  74333. get height(): string | number;
  74334. set height(value: string | number);
  74335. /**
  74336. * Gets or sets control height in pixel
  74337. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74338. */
  74339. get heightInPixels(): number;
  74340. set heightInPixels(value: number);
  74341. /** Gets or set font family */
  74342. get fontFamily(): string;
  74343. set fontFamily(value: string);
  74344. /** Gets or sets font style */
  74345. get fontStyle(): string;
  74346. set fontStyle(value: string);
  74347. /** Gets or sets font weight */
  74348. get fontWeight(): string;
  74349. set fontWeight(value: string);
  74350. /**
  74351. * Gets or sets style
  74352. * @see http://doc.babylonjs.com/how_to/gui#styles
  74353. */
  74354. get style(): BABYLON.Nullable<Style>;
  74355. set style(value: BABYLON.Nullable<Style>);
  74356. /** @hidden */
  74357. get _isFontSizeInPercentage(): boolean;
  74358. /** Gets or sets font size in pixels */
  74359. get fontSizeInPixels(): number;
  74360. set fontSizeInPixels(value: number);
  74361. /** Gets or sets font size */
  74362. get fontSize(): string | number;
  74363. set fontSize(value: string | number);
  74364. /** Gets or sets foreground color */
  74365. get color(): string;
  74366. set color(value: string);
  74367. /** Gets or sets z index which is used to reorder controls on the z axis */
  74368. get zIndex(): number;
  74369. set zIndex(value: number);
  74370. /** Gets or sets a boolean indicating if the control can be rendered */
  74371. get notRenderable(): boolean;
  74372. set notRenderable(value: boolean);
  74373. /** Gets or sets a boolean indicating if the control is visible */
  74374. get isVisible(): boolean;
  74375. set isVisible(value: boolean);
  74376. /** Gets a boolean indicating that the control needs to update its rendering */
  74377. get isDirty(): boolean;
  74378. /**
  74379. * Gets the current linked mesh (or null if none)
  74380. */
  74381. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  74382. /**
  74383. * Gets or sets a value indicating the padding to use on the left of the control
  74384. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74385. */
  74386. get paddingLeft(): string | number;
  74387. set paddingLeft(value: string | number);
  74388. /**
  74389. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  74390. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74391. */
  74392. get paddingLeftInPixels(): number;
  74393. set paddingLeftInPixels(value: number);
  74394. /**
  74395. * Gets or sets a value indicating the padding to use on the right of the control
  74396. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74397. */
  74398. get paddingRight(): string | number;
  74399. set paddingRight(value: string | number);
  74400. /**
  74401. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  74402. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74403. */
  74404. get paddingRightInPixels(): number;
  74405. set paddingRightInPixels(value: number);
  74406. /**
  74407. * Gets or sets a value indicating the padding to use on the top of the control
  74408. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74409. */
  74410. get paddingTop(): string | number;
  74411. set paddingTop(value: string | number);
  74412. /**
  74413. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  74414. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74415. */
  74416. get paddingTopInPixels(): number;
  74417. set paddingTopInPixels(value: number);
  74418. /**
  74419. * Gets or sets a value indicating the padding to use on the bottom of the control
  74420. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74421. */
  74422. get paddingBottom(): string | number;
  74423. set paddingBottom(value: string | number);
  74424. /**
  74425. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  74426. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74427. */
  74428. get paddingBottomInPixels(): number;
  74429. set paddingBottomInPixels(value: number);
  74430. /**
  74431. * Gets or sets a value indicating the left coordinate of the control
  74432. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74433. */
  74434. get left(): string | number;
  74435. set left(value: string | number);
  74436. /**
  74437. * Gets or sets a value indicating the left coordinate in pixels of the control
  74438. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74439. */
  74440. get leftInPixels(): number;
  74441. set leftInPixels(value: number);
  74442. /**
  74443. * Gets or sets a value indicating the top coordinate of the control
  74444. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74445. */
  74446. get top(): string | number;
  74447. set top(value: string | number);
  74448. /**
  74449. * Gets or sets a value indicating the top coordinate in pixels of the control
  74450. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74451. */
  74452. get topInPixels(): number;
  74453. set topInPixels(value: number);
  74454. /**
  74455. * Gets or sets a value indicating the offset on X axis to the linked mesh
  74456. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74457. */
  74458. get linkOffsetX(): string | number;
  74459. set linkOffsetX(value: string | number);
  74460. /**
  74461. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  74462. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74463. */
  74464. get linkOffsetXInPixels(): number;
  74465. set linkOffsetXInPixels(value: number);
  74466. /**
  74467. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  74468. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74469. */
  74470. get linkOffsetY(): string | number;
  74471. set linkOffsetY(value: string | number);
  74472. /**
  74473. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  74474. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74475. */
  74476. get linkOffsetYInPixels(): number;
  74477. set linkOffsetYInPixels(value: number);
  74478. /** Gets the center coordinate on X axis */
  74479. get centerX(): number;
  74480. /** Gets the center coordinate on Y axis */
  74481. get centerY(): number;
  74482. /** Gets or sets if control is Enabled*/
  74483. get isEnabled(): boolean;
  74484. set isEnabled(value: boolean);
  74485. /** Gets or sets background color of control if it's disabled*/
  74486. get disabledColor(): string;
  74487. set disabledColor(value: string);
  74488. /** Gets or sets front color of control if it's disabled*/
  74489. get disabledColorItem(): string;
  74490. set disabledColorItem(value: string);
  74491. /**
  74492. * Creates a new control
  74493. * @param name defines the name of the control
  74494. */
  74495. constructor(
  74496. /** defines the name of the control */
  74497. name?: string | undefined);
  74498. /** @hidden */
  74499. protected _getTypeName(): string;
  74500. /**
  74501. * Gets the first ascendant in the hierarchy of the given type
  74502. * @param className defines the required type
  74503. * @returns the ascendant or null if not found
  74504. */
  74505. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  74506. /** @hidden */
  74507. _resetFontCache(): void;
  74508. /**
  74509. * Determines if a container is an ascendant of the current control
  74510. * @param container defines the container to look for
  74511. * @returns true if the container is one of the ascendant of the control
  74512. */
  74513. isAscendant(container: Control): boolean;
  74514. /**
  74515. * Gets coordinates in local control space
  74516. * @param globalCoordinates defines the coordinates to transform
  74517. * @returns the new coordinates in local space
  74518. */
  74519. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  74520. /**
  74521. * Gets coordinates in local control space
  74522. * @param globalCoordinates defines the coordinates to transform
  74523. * @param result defines the target vector2 where to store the result
  74524. * @returns the current control
  74525. */
  74526. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  74527. /**
  74528. * Gets coordinates in parent local control space
  74529. * @param globalCoordinates defines the coordinates to transform
  74530. * @returns the new coordinates in parent local space
  74531. */
  74532. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  74533. /**
  74534. * Move the current control to a vector3 position projected onto the screen.
  74535. * @param position defines the target position
  74536. * @param scene defines the hosting scene
  74537. */
  74538. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  74539. /**
  74540. * Will store all controls that have this control as ascendant in a given array
  74541. * @param results defines the array where to store the descendants
  74542. * @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
  74543. * @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
  74544. */
  74545. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  74546. /**
  74547. * Will return all controls that have this control as ascendant
  74548. * @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
  74549. * @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
  74550. * @return all child controls
  74551. */
  74552. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  74553. /**
  74554. * Link current control with a target mesh
  74555. * @param mesh defines the mesh to link with
  74556. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74557. */
  74558. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  74559. /** @hidden */
  74560. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  74561. /** @hidden */
  74562. _offsetLeft(offset: number): void;
  74563. /** @hidden */
  74564. _offsetTop(offset: number): void;
  74565. /** @hidden */
  74566. _markMatrixAsDirty(): void;
  74567. /** @hidden */
  74568. _flagDescendantsAsMatrixDirty(): void;
  74569. /** @hidden */
  74570. _intersectsRect(rect: Measure): boolean;
  74571. /** @hidden */
  74572. protected invalidateRect(): void;
  74573. /** @hidden */
  74574. _markAsDirty(force?: boolean): void;
  74575. /** @hidden */
  74576. _markAllAsDirty(): void;
  74577. /** @hidden */
  74578. _link(host: AdvancedDynamicTexture): void;
  74579. /** @hidden */
  74580. protected _transform(context?: CanvasRenderingContext2D): void;
  74581. /** @hidden */
  74582. _renderHighlight(context: CanvasRenderingContext2D): void;
  74583. /** @hidden */
  74584. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  74585. /** @hidden */
  74586. protected _applyStates(context: CanvasRenderingContext2D): void;
  74587. /** @hidden */
  74588. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  74589. /** @hidden */
  74590. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74591. protected _evaluateClippingState(parentMeasure: Measure): void;
  74592. /** @hidden */
  74593. _measure(): void;
  74594. /** @hidden */
  74595. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74596. /** @hidden */
  74597. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74598. /** @hidden */
  74599. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74600. /** @hidden */
  74601. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  74602. private static _ClipMeasure;
  74603. private _tmpMeasureA;
  74604. private _clip;
  74605. /** @hidden */
  74606. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  74607. /** @hidden */
  74608. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74609. /**
  74610. * Tests if a given coordinates belong to the current control
  74611. * @param x defines x coordinate to test
  74612. * @param y defines y coordinate to test
  74613. * @returns true if the coordinates are inside the control
  74614. */
  74615. contains(x: number, y: number): boolean;
  74616. /** @hidden */
  74617. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  74618. /** @hidden */
  74619. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  74620. /** @hidden */
  74621. _onPointerEnter(target: Control): boolean;
  74622. /** @hidden */
  74623. _onPointerOut(target: Control, force?: boolean): void;
  74624. /** @hidden */
  74625. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74626. /** @hidden */
  74627. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  74628. /** @hidden */
  74629. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  74630. /** @hidden */
  74631. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  74632. /** @hidden */
  74633. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  74634. private _prepareFont;
  74635. /** Releases associated resources */
  74636. dispose(): void;
  74637. private static _HORIZONTAL_ALIGNMENT_LEFT;
  74638. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  74639. private static _HORIZONTAL_ALIGNMENT_CENTER;
  74640. private static _VERTICAL_ALIGNMENT_TOP;
  74641. private static _VERTICAL_ALIGNMENT_BOTTOM;
  74642. private static _VERTICAL_ALIGNMENT_CENTER;
  74643. /** HORIZONTAL_ALIGNMENT_LEFT */
  74644. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  74645. /** HORIZONTAL_ALIGNMENT_RIGHT */
  74646. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  74647. /** HORIZONTAL_ALIGNMENT_CENTER */
  74648. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  74649. /** VERTICAL_ALIGNMENT_TOP */
  74650. static get VERTICAL_ALIGNMENT_TOP(): number;
  74651. /** VERTICAL_ALIGNMENT_BOTTOM */
  74652. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  74653. /** VERTICAL_ALIGNMENT_CENTER */
  74654. static get VERTICAL_ALIGNMENT_CENTER(): number;
  74655. private static _FontHeightSizes;
  74656. /** @hidden */
  74657. static _GetFontOffset(font: string): {
  74658. ascent: number;
  74659. height: number;
  74660. descent: number;
  74661. };
  74662. /**
  74663. * Creates a stack panel that can be used to render headers
  74664. * @param control defines the control to associate with the header
  74665. * @param text defines the text of the header
  74666. * @param size defines the size of the header
  74667. * @param options defines options used to configure the header
  74668. * @returns a new StackPanel
  74669. * @ignore
  74670. * @hidden
  74671. */
  74672. static AddHeader: (control: Control, text: string, size: string | number, options: {
  74673. isHorizontal: boolean;
  74674. controlFirst: boolean;
  74675. }) => any;
  74676. /** @hidden */
  74677. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  74678. }
  74679. }
  74680. declare module BABYLON.GUI {
  74681. /**
  74682. * Root class for 2D containers
  74683. * @see http://doc.babylonjs.com/how_to/gui#containers
  74684. */
  74685. export class Container extends Control {
  74686. name?: string | undefined;
  74687. /** @hidden */
  74688. _children: Control[];
  74689. /** @hidden */
  74690. protected _measureForChildren: Measure;
  74691. /** @hidden */
  74692. protected _background: string;
  74693. /** @hidden */
  74694. protected _adaptWidthToChildren: boolean;
  74695. /** @hidden */
  74696. protected _adaptHeightToChildren: boolean;
  74697. /**
  74698. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  74699. */
  74700. logLayoutCycleErrors: boolean;
  74701. /**
  74702. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  74703. */
  74704. maxLayoutCycle: number;
  74705. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  74706. get adaptHeightToChildren(): boolean;
  74707. set adaptHeightToChildren(value: boolean);
  74708. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  74709. get adaptWidthToChildren(): boolean;
  74710. set adaptWidthToChildren(value: boolean);
  74711. /** Gets or sets background color */
  74712. get background(): string;
  74713. set background(value: string);
  74714. /** Gets the list of children */
  74715. get children(): Control[];
  74716. /**
  74717. * Creates a new Container
  74718. * @param name defines the name of the container
  74719. */
  74720. constructor(name?: string | undefined);
  74721. protected _getTypeName(): string;
  74722. _flagDescendantsAsMatrixDirty(): void;
  74723. /**
  74724. * Gets a child using its name
  74725. * @param name defines the child name to look for
  74726. * @returns the child control if found
  74727. */
  74728. getChildByName(name: string): BABYLON.Nullable<Control>;
  74729. /**
  74730. * Gets a child using its type and its name
  74731. * @param name defines the child name to look for
  74732. * @param type defines the child type to look for
  74733. * @returns the child control if found
  74734. */
  74735. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  74736. /**
  74737. * Search for a specific control in children
  74738. * @param control defines the control to look for
  74739. * @returns true if the control is in child list
  74740. */
  74741. containsControl(control: Control): boolean;
  74742. /**
  74743. * Adds a new control to the current container
  74744. * @param control defines the control to add
  74745. * @returns the current container
  74746. */
  74747. addControl(control: BABYLON.Nullable<Control>): Container;
  74748. /**
  74749. * Removes all controls from the current container
  74750. * @returns the current container
  74751. */
  74752. clearControls(): Container;
  74753. /**
  74754. * Removes a control from the current container
  74755. * @param control defines the control to remove
  74756. * @returns the current container
  74757. */
  74758. removeControl(control: Control): Container;
  74759. /** @hidden */
  74760. _reOrderControl(control: Control): void;
  74761. /** @hidden */
  74762. _offsetLeft(offset: number): void;
  74763. /** @hidden */
  74764. _offsetTop(offset: number): void;
  74765. /** @hidden */
  74766. _markAllAsDirty(): void;
  74767. /** @hidden */
  74768. protected _localDraw(context: CanvasRenderingContext2D): void;
  74769. /** @hidden */
  74770. _link(host: AdvancedDynamicTexture): void;
  74771. /** @hidden */
  74772. protected _beforeLayout(): void;
  74773. /** @hidden */
  74774. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74775. /** @hidden */
  74776. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  74777. protected _postMeasure(): void;
  74778. /** @hidden */
  74779. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  74780. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  74781. /** @hidden */
  74782. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  74783. /** @hidden */
  74784. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74785. /** Releases associated resources */
  74786. dispose(): void;
  74787. }
  74788. }
  74789. declare module BABYLON.GUI {
  74790. /** Class used to create rectangle container */
  74791. export class Rectangle extends Container {
  74792. name?: string | undefined;
  74793. private _thickness;
  74794. private _cornerRadius;
  74795. /** Gets or sets border thickness */
  74796. get thickness(): number;
  74797. set thickness(value: number);
  74798. /** Gets or sets the corner radius angle */
  74799. get cornerRadius(): number;
  74800. set cornerRadius(value: number);
  74801. /**
  74802. * Creates a new Rectangle
  74803. * @param name defines the control name
  74804. */
  74805. constructor(name?: string | undefined);
  74806. protected _getTypeName(): string;
  74807. protected _localDraw(context: CanvasRenderingContext2D): void;
  74808. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74809. private _drawRoundedRect;
  74810. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  74811. }
  74812. }
  74813. declare module BABYLON.GUI {
  74814. /**
  74815. * Enum that determines the text-wrapping mode to use.
  74816. */
  74817. export enum TextWrapping {
  74818. /**
  74819. * Clip the text when it's larger than Control.width; this is the default mode.
  74820. */
  74821. Clip = 0,
  74822. /**
  74823. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  74824. */
  74825. WordWrap = 1,
  74826. /**
  74827. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  74828. */
  74829. Ellipsis = 2
  74830. }
  74831. /**
  74832. * Class used to create text block control
  74833. */
  74834. export class TextBlock extends Control {
  74835. /**
  74836. * Defines the name of the control
  74837. */
  74838. name?: string | undefined;
  74839. private _text;
  74840. private _textWrapping;
  74841. private _textHorizontalAlignment;
  74842. private _textVerticalAlignment;
  74843. private _lines;
  74844. private _resizeToFit;
  74845. private _lineSpacing;
  74846. private _outlineWidth;
  74847. private _outlineColor;
  74848. /**
  74849. * An event triggered after the text is changed
  74850. */
  74851. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  74852. /**
  74853. * An event triggered after the text was broken up into lines
  74854. */
  74855. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  74856. /**
  74857. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  74858. */
  74859. get lines(): any[];
  74860. /**
  74861. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  74862. */
  74863. get resizeToFit(): boolean;
  74864. /**
  74865. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  74866. */
  74867. set resizeToFit(value: boolean);
  74868. /**
  74869. * Gets or sets a boolean indicating if text must be wrapped
  74870. */
  74871. get textWrapping(): TextWrapping | boolean;
  74872. /**
  74873. * Gets or sets a boolean indicating if text must be wrapped
  74874. */
  74875. set textWrapping(value: TextWrapping | boolean);
  74876. /**
  74877. * Gets or sets text to display
  74878. */
  74879. get text(): string;
  74880. /**
  74881. * Gets or sets text to display
  74882. */
  74883. set text(value: string);
  74884. /**
  74885. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  74886. */
  74887. get textHorizontalAlignment(): number;
  74888. /**
  74889. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  74890. */
  74891. set textHorizontalAlignment(value: number);
  74892. /**
  74893. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  74894. */
  74895. get textVerticalAlignment(): number;
  74896. /**
  74897. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  74898. */
  74899. set textVerticalAlignment(value: number);
  74900. /**
  74901. * Gets or sets line spacing value
  74902. */
  74903. set lineSpacing(value: string | number);
  74904. /**
  74905. * Gets or sets line spacing value
  74906. */
  74907. get lineSpacing(): string | number;
  74908. /**
  74909. * Gets or sets outlineWidth of the text to display
  74910. */
  74911. get outlineWidth(): number;
  74912. /**
  74913. * Gets or sets outlineWidth of the text to display
  74914. */
  74915. set outlineWidth(value: number);
  74916. /**
  74917. * Gets or sets outlineColor of the text to display
  74918. */
  74919. get outlineColor(): string;
  74920. /**
  74921. * Gets or sets outlineColor of the text to display
  74922. */
  74923. set outlineColor(value: string);
  74924. /**
  74925. * Creates a new TextBlock object
  74926. * @param name defines the name of the control
  74927. * @param text defines the text to display (emptry string by default)
  74928. */
  74929. constructor(
  74930. /**
  74931. * Defines the name of the control
  74932. */
  74933. name?: string | undefined, text?: string);
  74934. protected _getTypeName(): string;
  74935. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74936. private _drawText;
  74937. /** @hidden */
  74938. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74939. protected _applyStates(context: CanvasRenderingContext2D): void;
  74940. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  74941. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  74942. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  74943. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  74944. protected _renderLines(context: CanvasRenderingContext2D): void;
  74945. /**
  74946. * Given a width constraint applied on the text block, find the expected height
  74947. * @returns expected height
  74948. */
  74949. computeExpectedHeight(): number;
  74950. dispose(): void;
  74951. }
  74952. }
  74953. declare module BABYLON.GUI {
  74954. /**
  74955. * Class used to create 2D images
  74956. */
  74957. export class Image extends Control {
  74958. name?: string | undefined;
  74959. private _workingCanvas;
  74960. private _domImage;
  74961. private _imageWidth;
  74962. private _imageHeight;
  74963. private _loaded;
  74964. private _stretch;
  74965. private _source;
  74966. private _autoScale;
  74967. private _sourceLeft;
  74968. private _sourceTop;
  74969. private _sourceWidth;
  74970. private _sourceHeight;
  74971. private _svgAttributesComputationCompleted;
  74972. private _isSVG;
  74973. private _cellWidth;
  74974. private _cellHeight;
  74975. private _cellId;
  74976. private _populateNinePatchSlicesFromImage;
  74977. private _sliceLeft;
  74978. private _sliceRight;
  74979. private _sliceTop;
  74980. private _sliceBottom;
  74981. private _detectPointerOnOpaqueOnly;
  74982. /**
  74983. * BABYLON.Observable notified when the content is loaded
  74984. */
  74985. onImageLoadedObservable: BABYLON.Observable<Image>;
  74986. /**
  74987. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  74988. */
  74989. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  74990. /**
  74991. * Gets a boolean indicating that the content is loaded
  74992. */
  74993. get isLoaded(): boolean;
  74994. /**
  74995. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  74996. */
  74997. get populateNinePatchSlicesFromImage(): boolean;
  74998. set populateNinePatchSlicesFromImage(value: boolean);
  74999. /**
  75000. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  75001. * Beware using this as this will comsume more memory as the image has to be stored twice
  75002. */
  75003. get detectPointerOnOpaqueOnly(): boolean;
  75004. set detectPointerOnOpaqueOnly(value: boolean);
  75005. /**
  75006. * Gets or sets the left value for slicing (9-patch)
  75007. */
  75008. get sliceLeft(): number;
  75009. set sliceLeft(value: number);
  75010. /**
  75011. * Gets or sets the right value for slicing (9-patch)
  75012. */
  75013. get sliceRight(): number;
  75014. set sliceRight(value: number);
  75015. /**
  75016. * Gets or sets the top value for slicing (9-patch)
  75017. */
  75018. get sliceTop(): number;
  75019. set sliceTop(value: number);
  75020. /**
  75021. * Gets or sets the bottom value for slicing (9-patch)
  75022. */
  75023. get sliceBottom(): number;
  75024. set sliceBottom(value: number);
  75025. /**
  75026. * Gets or sets the left coordinate in the source image
  75027. */
  75028. get sourceLeft(): number;
  75029. set sourceLeft(value: number);
  75030. /**
  75031. * Gets or sets the top coordinate in the source image
  75032. */
  75033. get sourceTop(): number;
  75034. set sourceTop(value: number);
  75035. /**
  75036. * Gets or sets the width to capture in the source image
  75037. */
  75038. get sourceWidth(): number;
  75039. set sourceWidth(value: number);
  75040. /**
  75041. * Gets or sets the height to capture in the source image
  75042. */
  75043. get sourceHeight(): number;
  75044. set sourceHeight(value: number);
  75045. /** Indicates if the format of the image is SVG */
  75046. get isSVG(): boolean;
  75047. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  75048. get svgAttributesComputationCompleted(): boolean;
  75049. /**
  75050. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  75051. * @see http://doc.babylonjs.com/how_to/gui#image
  75052. */
  75053. get autoScale(): boolean;
  75054. set autoScale(value: boolean);
  75055. /** Gets or sets the streching mode used by the image */
  75056. get stretch(): number;
  75057. set stretch(value: number);
  75058. /** @hidden */
  75059. _rotate90(n: number, preserveProperties?: boolean): Image;
  75060. private _handleRotationForSVGImage;
  75061. private _rotate90SourceProperties;
  75062. /**
  75063. * Gets or sets the internal DOM image used to render the control
  75064. */
  75065. set domImage(value: HTMLImageElement);
  75066. get domImage(): HTMLImageElement;
  75067. private _onImageLoaded;
  75068. private _extractNinePatchSliceDataFromImage;
  75069. /**
  75070. * Gets or sets image source url
  75071. */
  75072. set source(value: BABYLON.Nullable<string>);
  75073. /**
  75074. * Checks for svg document with icon id present
  75075. */
  75076. private _svgCheck;
  75077. /**
  75078. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  75079. * given external svg file and icon id
  75080. */
  75081. private _getSVGAttribs;
  75082. /**
  75083. * Gets or sets the cell width to use when animation sheet is enabled
  75084. * @see http://doc.babylonjs.com/how_to/gui#image
  75085. */
  75086. get cellWidth(): number;
  75087. set cellWidth(value: number);
  75088. /**
  75089. * Gets or sets the cell height to use when animation sheet is enabled
  75090. * @see http://doc.babylonjs.com/how_to/gui#image
  75091. */
  75092. get cellHeight(): number;
  75093. set cellHeight(value: number);
  75094. /**
  75095. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  75096. * @see http://doc.babylonjs.com/how_to/gui#image
  75097. */
  75098. get cellId(): number;
  75099. set cellId(value: number);
  75100. /**
  75101. * Creates a new Image
  75102. * @param name defines the control name
  75103. * @param url defines the image url
  75104. */
  75105. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  75106. /**
  75107. * Tests if a given coordinates belong to the current control
  75108. * @param x defines x coordinate to test
  75109. * @param y defines y coordinate to test
  75110. * @returns true if the coordinates are inside the control
  75111. */
  75112. contains(x: number, y: number): boolean;
  75113. protected _getTypeName(): string;
  75114. /** Force the control to synchronize with its content */
  75115. synchronizeSizeWithContent(): void;
  75116. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75117. private _prepareWorkingCanvasForOpaqueDetection;
  75118. private _drawImage;
  75119. _draw(context: CanvasRenderingContext2D): void;
  75120. private _renderCornerPatch;
  75121. private _renderNinePatch;
  75122. dispose(): void;
  75123. /** STRETCH_NONE */
  75124. static readonly STRETCH_NONE: number;
  75125. /** STRETCH_FILL */
  75126. static readonly STRETCH_FILL: number;
  75127. /** STRETCH_UNIFORM */
  75128. static readonly STRETCH_UNIFORM: number;
  75129. /** STRETCH_EXTEND */
  75130. static readonly STRETCH_EXTEND: number;
  75131. /** NINE_PATCH */
  75132. static readonly STRETCH_NINE_PATCH: number;
  75133. }
  75134. }
  75135. declare module BABYLON.GUI {
  75136. /**
  75137. * Class used to create 2D buttons
  75138. */
  75139. export class Button extends Rectangle {
  75140. name?: string | undefined;
  75141. /**
  75142. * Function called to generate a pointer enter animation
  75143. */
  75144. pointerEnterAnimation: () => void;
  75145. /**
  75146. * Function called to generate a pointer out animation
  75147. */
  75148. pointerOutAnimation: () => void;
  75149. /**
  75150. * Function called to generate a pointer down animation
  75151. */
  75152. pointerDownAnimation: () => void;
  75153. /**
  75154. * Function called to generate a pointer up animation
  75155. */
  75156. pointerUpAnimation: () => void;
  75157. /**
  75158. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  75159. */
  75160. delegatePickingToChildren: boolean;
  75161. private _image;
  75162. /**
  75163. * Returns the image part of the button (if any)
  75164. */
  75165. get image(): BABYLON.Nullable<Image>;
  75166. private _textBlock;
  75167. /**
  75168. * Returns the image part of the button (if any)
  75169. */
  75170. get textBlock(): BABYLON.Nullable<TextBlock>;
  75171. /**
  75172. * Creates a new Button
  75173. * @param name defines the name of the button
  75174. */
  75175. constructor(name?: string | undefined);
  75176. protected _getTypeName(): string;
  75177. /** @hidden */
  75178. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75179. /** @hidden */
  75180. _onPointerEnter(target: Control): boolean;
  75181. /** @hidden */
  75182. _onPointerOut(target: Control, force?: boolean): void;
  75183. /** @hidden */
  75184. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75185. /** @hidden */
  75186. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75187. /**
  75188. * Creates a new button made with an image and a text
  75189. * @param name defines the name of the button
  75190. * @param text defines the text of the button
  75191. * @param imageUrl defines the url of the image
  75192. * @returns a new Button
  75193. */
  75194. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  75195. /**
  75196. * Creates a new button made with an image
  75197. * @param name defines the name of the button
  75198. * @param imageUrl defines the url of the image
  75199. * @returns a new Button
  75200. */
  75201. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  75202. /**
  75203. * Creates a new button made with a text
  75204. * @param name defines the name of the button
  75205. * @param text defines the text of the button
  75206. * @returns a new Button
  75207. */
  75208. static CreateSimpleButton(name: string, text: string): Button;
  75209. /**
  75210. * Creates a new button made with an image and a centered text
  75211. * @param name defines the name of the button
  75212. * @param text defines the text of the button
  75213. * @param imageUrl defines the url of the image
  75214. * @returns a new Button
  75215. */
  75216. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  75217. }
  75218. }
  75219. declare module BABYLON.GUI {
  75220. /**
  75221. * Class used to create a 2D stack panel container
  75222. */
  75223. export class StackPanel extends Container {
  75224. name?: string | undefined;
  75225. private _isVertical;
  75226. private _manualWidth;
  75227. private _manualHeight;
  75228. private _doNotTrackManualChanges;
  75229. /**
  75230. * Gets or sets a boolean indicating that layou warnings should be ignored
  75231. */
  75232. ignoreLayoutWarnings: boolean;
  75233. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  75234. get isVertical(): boolean;
  75235. set isVertical(value: boolean);
  75236. /**
  75237. * Gets or sets panel width.
  75238. * This value should not be set when in horizontal mode as it will be computed automatically
  75239. */
  75240. set width(value: string | number);
  75241. get width(): string | number;
  75242. /**
  75243. * Gets or sets panel height.
  75244. * This value should not be set when in vertical mode as it will be computed automatically
  75245. */
  75246. set height(value: string | number);
  75247. get height(): string | number;
  75248. /**
  75249. * Creates a new StackPanel
  75250. * @param name defines control name
  75251. */
  75252. constructor(name?: string | undefined);
  75253. protected _getTypeName(): string;
  75254. /** @hidden */
  75255. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75256. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75257. protected _postMeasure(): void;
  75258. }
  75259. }
  75260. declare module BABYLON.GUI {
  75261. /**
  75262. * Class used to represent a 2D checkbox
  75263. */
  75264. export class Checkbox extends Control {
  75265. name?: string | undefined;
  75266. private _isChecked;
  75267. private _background;
  75268. private _checkSizeRatio;
  75269. private _thickness;
  75270. /** Gets or sets border thickness */
  75271. get thickness(): number;
  75272. set thickness(value: number);
  75273. /**
  75274. * BABYLON.Observable raised when isChecked property changes
  75275. */
  75276. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  75277. /** Gets or sets a value indicating the ratio between overall size and check size */
  75278. get checkSizeRatio(): number;
  75279. set checkSizeRatio(value: number);
  75280. /** Gets or sets background color */
  75281. get background(): string;
  75282. set background(value: string);
  75283. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  75284. get isChecked(): boolean;
  75285. set isChecked(value: boolean);
  75286. /**
  75287. * Creates a new CheckBox
  75288. * @param name defines the control name
  75289. */
  75290. constructor(name?: string | undefined);
  75291. protected _getTypeName(): string;
  75292. /** @hidden */
  75293. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75294. /** @hidden */
  75295. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75296. /**
  75297. * Utility function to easily create a checkbox with a header
  75298. * @param title defines the label to use for the header
  75299. * @param onValueChanged defines the callback to call when value changes
  75300. * @returns a StackPanel containing the checkbox and a textBlock
  75301. */
  75302. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  75303. }
  75304. }
  75305. declare module BABYLON.GUI {
  75306. /**
  75307. * Class used to store key control properties
  75308. */
  75309. export class KeyPropertySet {
  75310. /** Width */
  75311. width?: string;
  75312. /** Height */
  75313. height?: string;
  75314. /** Left padding */
  75315. paddingLeft?: string;
  75316. /** Right padding */
  75317. paddingRight?: string;
  75318. /** Top padding */
  75319. paddingTop?: string;
  75320. /** Bottom padding */
  75321. paddingBottom?: string;
  75322. /** Foreground color */
  75323. color?: string;
  75324. /** Background color */
  75325. background?: string;
  75326. }
  75327. /**
  75328. * Class used to create virtual keyboard
  75329. */
  75330. export class VirtualKeyboard extends StackPanel {
  75331. /** BABYLON.Observable raised when a key is pressed */
  75332. onKeyPressObservable: BABYLON.Observable<string>;
  75333. /** Gets or sets default key button width */
  75334. defaultButtonWidth: string;
  75335. /** Gets or sets default key button height */
  75336. defaultButtonHeight: string;
  75337. /** Gets or sets default key button left padding */
  75338. defaultButtonPaddingLeft: string;
  75339. /** Gets or sets default key button right padding */
  75340. defaultButtonPaddingRight: string;
  75341. /** Gets or sets default key button top padding */
  75342. defaultButtonPaddingTop: string;
  75343. /** Gets or sets default key button bottom padding */
  75344. defaultButtonPaddingBottom: string;
  75345. /** Gets or sets default key button foreground color */
  75346. defaultButtonColor: string;
  75347. /** Gets or sets default key button background color */
  75348. defaultButtonBackground: string;
  75349. /** Gets or sets shift button foreground color */
  75350. shiftButtonColor: string;
  75351. /** Gets or sets shift button thickness*/
  75352. selectedShiftThickness: number;
  75353. /** Gets shift key state */
  75354. shiftState: number;
  75355. protected _getTypeName(): string;
  75356. private _createKey;
  75357. /**
  75358. * Adds a new row of keys
  75359. * @param keys defines the list of keys to add
  75360. * @param propertySets defines the associated property sets
  75361. */
  75362. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  75363. /**
  75364. * Set the shift key to a specific state
  75365. * @param shiftState defines the new shift state
  75366. */
  75367. applyShiftState(shiftState: number): void;
  75368. private _currentlyConnectedInputText;
  75369. private _connectedInputTexts;
  75370. private _onKeyPressObserver;
  75371. /** Gets the input text control currently attached to the keyboard */
  75372. get connectedInputText(): BABYLON.Nullable<InputText>;
  75373. /**
  75374. * Connects the keyboard with an input text control
  75375. *
  75376. * @param input defines the target control
  75377. */
  75378. connect(input: InputText): void;
  75379. /**
  75380. * Disconnects the keyboard from connected InputText controls
  75381. *
  75382. * @param input optionally defines a target control, otherwise all are disconnected
  75383. */
  75384. disconnect(input?: InputText): void;
  75385. private _removeConnectedInputObservables;
  75386. /**
  75387. * Release all resources
  75388. */
  75389. dispose(): void;
  75390. /**
  75391. * Creates a new keyboard using a default layout
  75392. *
  75393. * @param name defines control name
  75394. * @returns a new VirtualKeyboard
  75395. */
  75396. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  75397. }
  75398. }
  75399. declare module BABYLON.GUI {
  75400. /**
  75401. * Class used to create input text control
  75402. */
  75403. export class InputText extends Control implements IFocusableControl {
  75404. name?: string | undefined;
  75405. private _text;
  75406. private _placeholderText;
  75407. private _background;
  75408. private _focusedBackground;
  75409. private _focusedColor;
  75410. private _placeholderColor;
  75411. private _thickness;
  75412. private _margin;
  75413. private _autoStretchWidth;
  75414. private _maxWidth;
  75415. private _isFocused;
  75416. private _blinkTimeout;
  75417. private _blinkIsEven;
  75418. private _cursorOffset;
  75419. private _scrollLeft;
  75420. private _textWidth;
  75421. private _clickedCoordinate;
  75422. private _deadKey;
  75423. private _addKey;
  75424. private _currentKey;
  75425. private _isTextHighlightOn;
  75426. private _textHighlightColor;
  75427. private _highligherOpacity;
  75428. private _highlightedText;
  75429. private _startHighlightIndex;
  75430. private _endHighlightIndex;
  75431. private _cursorIndex;
  75432. private _onFocusSelectAll;
  75433. private _isPointerDown;
  75434. private _onClipboardObserver;
  75435. private _onPointerDblTapObserver;
  75436. /** @hidden */
  75437. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  75438. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  75439. promptMessage: string;
  75440. /** Force disable prompt on mobile device */
  75441. disableMobilePrompt: boolean;
  75442. /** BABYLON.Observable raised when the text changes */
  75443. onTextChangedObservable: BABYLON.Observable<InputText>;
  75444. /** BABYLON.Observable raised just before an entered character is to be added */
  75445. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  75446. /** BABYLON.Observable raised when the control gets the focus */
  75447. onFocusObservable: BABYLON.Observable<InputText>;
  75448. /** BABYLON.Observable raised when the control loses the focus */
  75449. onBlurObservable: BABYLON.Observable<InputText>;
  75450. /**Observable raised when the text is highlighted */
  75451. onTextHighlightObservable: BABYLON.Observable<InputText>;
  75452. /**Observable raised when copy event is triggered */
  75453. onTextCopyObservable: BABYLON.Observable<InputText>;
  75454. /** BABYLON.Observable raised when cut event is triggered */
  75455. onTextCutObservable: BABYLON.Observable<InputText>;
  75456. /** BABYLON.Observable raised when paste event is triggered */
  75457. onTextPasteObservable: BABYLON.Observable<InputText>;
  75458. /** BABYLON.Observable raised when a key event was processed */
  75459. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  75460. /** Gets or sets the maximum width allowed by the control */
  75461. get maxWidth(): string | number;
  75462. /** Gets the maximum width allowed by the control in pixels */
  75463. get maxWidthInPixels(): number;
  75464. set maxWidth(value: string | number);
  75465. /** Gets or sets the text highlighter transparency; default: 0.4 */
  75466. get highligherOpacity(): number;
  75467. set highligherOpacity(value: number);
  75468. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  75469. get onFocusSelectAll(): boolean;
  75470. set onFocusSelectAll(value: boolean);
  75471. /** Gets or sets the text hightlight color */
  75472. get textHighlightColor(): string;
  75473. set textHighlightColor(value: string);
  75474. /** Gets or sets control margin */
  75475. get margin(): string;
  75476. /** Gets control margin in pixels */
  75477. get marginInPixels(): number;
  75478. set margin(value: string);
  75479. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  75480. get autoStretchWidth(): boolean;
  75481. set autoStretchWidth(value: boolean);
  75482. /** Gets or sets border thickness */
  75483. get thickness(): number;
  75484. set thickness(value: number);
  75485. /** Gets or sets the background color when focused */
  75486. get focusedBackground(): string;
  75487. set focusedBackground(value: string);
  75488. /** Gets or sets the background color when focused */
  75489. get focusedColor(): string;
  75490. set focusedColor(value: string);
  75491. /** Gets or sets the background color */
  75492. get background(): string;
  75493. set background(value: string);
  75494. /** Gets or sets the placeholder color */
  75495. get placeholderColor(): string;
  75496. set placeholderColor(value: string);
  75497. /** Gets or sets the text displayed when the control is empty */
  75498. get placeholderText(): string;
  75499. set placeholderText(value: string);
  75500. /** Gets or sets the dead key flag */
  75501. get deadKey(): boolean;
  75502. set deadKey(flag: boolean);
  75503. /** Gets or sets the highlight text */
  75504. get highlightedText(): string;
  75505. set highlightedText(text: string);
  75506. /** Gets or sets if the current key should be added */
  75507. get addKey(): boolean;
  75508. set addKey(flag: boolean);
  75509. /** Gets or sets the value of the current key being entered */
  75510. get currentKey(): string;
  75511. set currentKey(key: string);
  75512. /** Gets or sets the text displayed in the control */
  75513. get text(): string;
  75514. set text(value: string);
  75515. /** Gets or sets control width */
  75516. get width(): string | number;
  75517. set width(value: string | number);
  75518. /**
  75519. * Creates a new InputText
  75520. * @param name defines the control name
  75521. * @param text defines the text of the control
  75522. */
  75523. constructor(name?: string | undefined, text?: string);
  75524. /** @hidden */
  75525. onBlur(): void;
  75526. /** @hidden */
  75527. onFocus(): void;
  75528. protected _getTypeName(): string;
  75529. /**
  75530. * Function called to get the list of controls that should not steal the focus from this control
  75531. * @returns an array of controls
  75532. */
  75533. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  75534. /** @hidden */
  75535. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  75536. /** @hidden */
  75537. private _updateValueFromCursorIndex;
  75538. /** @hidden */
  75539. private _processDblClick;
  75540. /** @hidden */
  75541. private _selectAllText;
  75542. /**
  75543. * Handles the keyboard event
  75544. * @param evt Defines the KeyboardEvent
  75545. */
  75546. processKeyboard(evt: KeyboardEvent): void;
  75547. /** @hidden */
  75548. private _onCopyText;
  75549. /** @hidden */
  75550. private _onCutText;
  75551. /** @hidden */
  75552. private _onPasteText;
  75553. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75554. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75555. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  75556. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75557. protected _beforeRenderText(text: string): string;
  75558. dispose(): void;
  75559. }
  75560. }
  75561. declare module BABYLON.GUI {
  75562. /**
  75563. * Class used to create a 2D grid container
  75564. */
  75565. export class Grid extends Container {
  75566. name?: string | undefined;
  75567. private _rowDefinitions;
  75568. private _columnDefinitions;
  75569. private _cells;
  75570. private _childControls;
  75571. /**
  75572. * Gets the number of columns
  75573. */
  75574. get columnCount(): number;
  75575. /**
  75576. * Gets the number of rows
  75577. */
  75578. get rowCount(): number;
  75579. /** Gets the list of children */
  75580. get children(): Control[];
  75581. /** Gets the list of cells (e.g. the containers) */
  75582. get cells(): {
  75583. [key: string]: Container;
  75584. };
  75585. /**
  75586. * Gets the definition of a specific row
  75587. * @param index defines the index of the row
  75588. * @returns the row definition
  75589. */
  75590. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  75591. /**
  75592. * Gets the definition of a specific column
  75593. * @param index defines the index of the column
  75594. * @returns the column definition
  75595. */
  75596. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  75597. /**
  75598. * Adds a new row to the grid
  75599. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  75600. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  75601. * @returns the current grid
  75602. */
  75603. addRowDefinition(height: number, isPixel?: boolean): Grid;
  75604. /**
  75605. * Adds a new column to the grid
  75606. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  75607. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  75608. * @returns the current grid
  75609. */
  75610. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  75611. /**
  75612. * Update a row definition
  75613. * @param index defines the index of the row to update
  75614. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  75615. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  75616. * @returns the current grid
  75617. */
  75618. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  75619. /**
  75620. * Update a column definition
  75621. * @param index defines the index of the column to update
  75622. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  75623. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  75624. * @returns the current grid
  75625. */
  75626. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  75627. /**
  75628. * Gets the list of children stored in a specific cell
  75629. * @param row defines the row to check
  75630. * @param column defines the column to check
  75631. * @returns the list of controls
  75632. */
  75633. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  75634. /**
  75635. * Gets a string representing the child cell info (row x column)
  75636. * @param child defines the control to get info from
  75637. * @returns a string containing the child cell info (row x column)
  75638. */
  75639. getChildCellInfo(child: Control): string;
  75640. private _removeCell;
  75641. private _offsetCell;
  75642. /**
  75643. * Remove a column definition at specified index
  75644. * @param index defines the index of the column to remove
  75645. * @returns the current grid
  75646. */
  75647. removeColumnDefinition(index: number): Grid;
  75648. /**
  75649. * Remove a row definition at specified index
  75650. * @param index defines the index of the row to remove
  75651. * @returns the current grid
  75652. */
  75653. removeRowDefinition(index: number): Grid;
  75654. /**
  75655. * Adds a new control to the current grid
  75656. * @param control defines the control to add
  75657. * @param row defines the row where to add the control (0 by default)
  75658. * @param column defines the column where to add the control (0 by default)
  75659. * @returns the current grid
  75660. */
  75661. addControl(control: Control, row?: number, column?: number): Grid;
  75662. /**
  75663. * Removes a control from the current container
  75664. * @param control defines the control to remove
  75665. * @returns the current container
  75666. */
  75667. removeControl(control: Control): Container;
  75668. /**
  75669. * Creates a new Grid
  75670. * @param name defines control name
  75671. */
  75672. constructor(name?: string | undefined);
  75673. protected _getTypeName(): string;
  75674. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  75675. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75676. _flagDescendantsAsMatrixDirty(): void;
  75677. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  75678. /** Releases associated resources */
  75679. dispose(): void;
  75680. }
  75681. }
  75682. declare module BABYLON.GUI {
  75683. /** Class used to create color pickers */
  75684. export class ColorPicker extends Control {
  75685. name?: string | undefined;
  75686. private static _Epsilon;
  75687. private _colorWheelCanvas;
  75688. private _value;
  75689. private _tmpColor;
  75690. private _pointerStartedOnSquare;
  75691. private _pointerStartedOnWheel;
  75692. private _squareLeft;
  75693. private _squareTop;
  75694. private _squareSize;
  75695. private _h;
  75696. private _s;
  75697. private _v;
  75698. private _lastPointerDownID;
  75699. /**
  75700. * BABYLON.Observable raised when the value changes
  75701. */
  75702. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  75703. /** Gets or sets the color of the color picker */
  75704. get value(): BABYLON.Color3;
  75705. set value(value: BABYLON.Color3);
  75706. /**
  75707. * Gets or sets control width
  75708. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75709. */
  75710. get width(): string | number;
  75711. set width(value: string | number);
  75712. /**
  75713. * Gets or sets control height
  75714. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75715. */
  75716. get height(): string | number;
  75717. /** Gets or sets control height */
  75718. set height(value: string | number);
  75719. /** Gets or sets control size */
  75720. get size(): string | number;
  75721. set size(value: string | number);
  75722. /**
  75723. * Creates a new ColorPicker
  75724. * @param name defines the control name
  75725. */
  75726. constructor(name?: string | undefined);
  75727. protected _getTypeName(): string;
  75728. /** @hidden */
  75729. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75730. private _updateSquareProps;
  75731. private _drawGradientSquare;
  75732. private _drawCircle;
  75733. private _createColorWheelCanvas;
  75734. /** @hidden */
  75735. _draw(context: CanvasRenderingContext2D): void;
  75736. private _pointerIsDown;
  75737. private _updateValueFromPointer;
  75738. private _isPointOnSquare;
  75739. private _isPointOnWheel;
  75740. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75741. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  75742. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75743. /**
  75744. * This function expands the color picker by creating a color picker dialog with manual
  75745. * color value input and the ability to save colors into an array to be used later in
  75746. * subsequent launches of the dialogue.
  75747. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  75748. * @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.
  75749. * @returns picked color as a hex string and the saved colors array as hex strings.
  75750. */
  75751. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  75752. pickerWidth?: string;
  75753. pickerHeight?: string;
  75754. headerHeight?: string;
  75755. lastColor?: string;
  75756. swatchLimit?: number;
  75757. numSwatchesPerLine?: number;
  75758. savedColors?: Array<string>;
  75759. }): Promise<{
  75760. savedColors?: string[];
  75761. pickedColor: string;
  75762. }>;
  75763. }
  75764. }
  75765. declare module BABYLON.GUI {
  75766. /** Class used to create 2D ellipse containers */
  75767. export class Ellipse extends Container {
  75768. name?: string | undefined;
  75769. private _thickness;
  75770. /** Gets or sets border thickness */
  75771. get thickness(): number;
  75772. set thickness(value: number);
  75773. /**
  75774. * Creates a new Ellipse
  75775. * @param name defines the control name
  75776. */
  75777. constructor(name?: string | undefined);
  75778. protected _getTypeName(): string;
  75779. protected _localDraw(context: CanvasRenderingContext2D): void;
  75780. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75781. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  75782. }
  75783. }
  75784. declare module BABYLON.GUI {
  75785. /**
  75786. * Class used to create a password control
  75787. */
  75788. export class InputPassword extends InputText {
  75789. protected _beforeRenderText(text: string): string;
  75790. }
  75791. }
  75792. declare module BABYLON.GUI {
  75793. /** Class used to render 2D lines */
  75794. export class Line extends Control {
  75795. name?: string | undefined;
  75796. private _lineWidth;
  75797. private _x1;
  75798. private _y1;
  75799. private _x2;
  75800. private _y2;
  75801. private _dash;
  75802. private _connectedControl;
  75803. private _connectedControlDirtyObserver;
  75804. /** Gets or sets the dash pattern */
  75805. get dash(): Array<number>;
  75806. set dash(value: Array<number>);
  75807. /** Gets or sets the control connected with the line end */
  75808. get connectedControl(): Control;
  75809. set connectedControl(value: Control);
  75810. /** Gets or sets start coordinates on X axis */
  75811. get x1(): string | number;
  75812. set x1(value: string | number);
  75813. /** Gets or sets start coordinates on Y axis */
  75814. get y1(): string | number;
  75815. set y1(value: string | number);
  75816. /** Gets or sets end coordinates on X axis */
  75817. get x2(): string | number;
  75818. set x2(value: string | number);
  75819. /** Gets or sets end coordinates on Y axis */
  75820. get y2(): string | number;
  75821. set y2(value: string | number);
  75822. /** Gets or sets line width */
  75823. get lineWidth(): number;
  75824. set lineWidth(value: number);
  75825. /** Gets or sets horizontal alignment */
  75826. set horizontalAlignment(value: number);
  75827. /** Gets or sets vertical alignment */
  75828. set verticalAlignment(value: number);
  75829. private get _effectiveX2();
  75830. private get _effectiveY2();
  75831. /**
  75832. * Creates a new Line
  75833. * @param name defines the control name
  75834. */
  75835. constructor(name?: string | undefined);
  75836. protected _getTypeName(): string;
  75837. _draw(context: CanvasRenderingContext2D): void;
  75838. _measure(): void;
  75839. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75840. /**
  75841. * Move one end of the line given 3D cartesian coordinates.
  75842. * @param position Targeted world position
  75843. * @param scene BABYLON.Scene
  75844. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  75845. */
  75846. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  75847. /**
  75848. * Move one end of the line to a position in screen absolute space.
  75849. * @param projectedPosition Position in screen absolute space (X, Y)
  75850. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  75851. */
  75852. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  75853. }
  75854. }
  75855. declare module BABYLON.GUI {
  75856. /**
  75857. * Class used to store a point for a MultiLine object.
  75858. * The point can be pure 2D coordinates, a mesh or a control
  75859. */
  75860. export class MultiLinePoint {
  75861. private _multiLine;
  75862. private _x;
  75863. private _y;
  75864. private _control;
  75865. private _mesh;
  75866. private _controlObserver;
  75867. private _meshObserver;
  75868. /** @hidden */
  75869. _point: BABYLON.Vector2;
  75870. /**
  75871. * Creates a new MultiLinePoint
  75872. * @param multiLine defines the source MultiLine object
  75873. */
  75874. constructor(multiLine: MultiLine);
  75875. /** Gets or sets x coordinate */
  75876. get x(): string | number;
  75877. set x(value: string | number);
  75878. /** Gets or sets y coordinate */
  75879. get y(): string | number;
  75880. set y(value: string | number);
  75881. /** Gets or sets the control associated with this point */
  75882. get control(): BABYLON.Nullable<Control>;
  75883. set control(value: BABYLON.Nullable<Control>);
  75884. /** Gets or sets the mesh associated with this point */
  75885. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  75886. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  75887. /** Resets links */
  75888. resetLinks(): void;
  75889. /**
  75890. * Gets a translation vector
  75891. * @returns the translation vector
  75892. */
  75893. translate(): BABYLON.Vector2;
  75894. private _translatePoint;
  75895. /** Release associated resources */
  75896. dispose(): void;
  75897. }
  75898. }
  75899. declare module BABYLON.GUI {
  75900. /**
  75901. * Class used to create multi line control
  75902. */
  75903. export class MultiLine extends Control {
  75904. name?: string | undefined;
  75905. private _lineWidth;
  75906. private _dash;
  75907. private _points;
  75908. private _minX;
  75909. private _minY;
  75910. private _maxX;
  75911. private _maxY;
  75912. /**
  75913. * Creates a new MultiLine
  75914. * @param name defines the control name
  75915. */
  75916. constructor(name?: string | undefined);
  75917. /** Gets or sets dash pattern */
  75918. get dash(): Array<number>;
  75919. set dash(value: Array<number>);
  75920. /**
  75921. * Gets point stored at specified index
  75922. * @param index defines the index to look for
  75923. * @returns the requested point if found
  75924. */
  75925. getAt(index: number): MultiLinePoint;
  75926. /** Function called when a point is updated */
  75927. onPointUpdate: () => void;
  75928. /**
  75929. * Adds new points to the point collection
  75930. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  75931. * @returns the list of created MultiLinePoint
  75932. */
  75933. add(...items: (AbstractMesh | Control | {
  75934. x: string | number;
  75935. y: string | number;
  75936. })[]): MultiLinePoint[];
  75937. /**
  75938. * Adds a new point to the point collection
  75939. * @param item defines the item (mesh, control or 2d coordiantes) to add
  75940. * @returns the created MultiLinePoint
  75941. */
  75942. push(item?: (AbstractMesh | Control | {
  75943. x: string | number;
  75944. y: string | number;
  75945. })): MultiLinePoint;
  75946. /**
  75947. * Remove a specific value or point from the active point collection
  75948. * @param value defines the value or point to remove
  75949. */
  75950. remove(value: number | MultiLinePoint): void;
  75951. /**
  75952. * Resets this object to initial state (no point)
  75953. */
  75954. reset(): void;
  75955. /**
  75956. * Resets all links
  75957. */
  75958. resetLinks(): void;
  75959. /** Gets or sets line width */
  75960. get lineWidth(): number;
  75961. set lineWidth(value: number);
  75962. set horizontalAlignment(value: number);
  75963. set verticalAlignment(value: number);
  75964. protected _getTypeName(): string;
  75965. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75966. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75967. _measure(): void;
  75968. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75969. dispose(): void;
  75970. }
  75971. }
  75972. declare module BABYLON.GUI {
  75973. /**
  75974. * Class used to create radio button controls
  75975. */
  75976. export class RadioButton extends Control {
  75977. name?: string | undefined;
  75978. private _isChecked;
  75979. private _background;
  75980. private _checkSizeRatio;
  75981. private _thickness;
  75982. /** Gets or sets border thickness */
  75983. get thickness(): number;
  75984. set thickness(value: number);
  75985. /** Gets or sets group name */
  75986. group: string;
  75987. /** BABYLON.Observable raised when isChecked is changed */
  75988. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  75989. /** Gets or sets a value indicating the ratio between overall size and check size */
  75990. get checkSizeRatio(): number;
  75991. set checkSizeRatio(value: number);
  75992. /** Gets or sets background color */
  75993. get background(): string;
  75994. set background(value: string);
  75995. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  75996. get isChecked(): boolean;
  75997. set isChecked(value: boolean);
  75998. /**
  75999. * Creates a new RadioButton
  76000. * @param name defines the control name
  76001. */
  76002. constructor(name?: string | undefined);
  76003. protected _getTypeName(): string;
  76004. _draw(context: CanvasRenderingContext2D): void;
  76005. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76006. /**
  76007. * Utility function to easily create a radio button with a header
  76008. * @param title defines the label to use for the header
  76009. * @param group defines the group to use for the radio button
  76010. * @param isChecked defines the initial state of the radio button
  76011. * @param onValueChanged defines the callback to call when value changes
  76012. * @returns a StackPanel containing the radio button and a textBlock
  76013. */
  76014. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  76015. }
  76016. }
  76017. declare module BABYLON.GUI {
  76018. /**
  76019. * Class used to create slider controls
  76020. */
  76021. export class BaseSlider extends Control {
  76022. name?: string | undefined;
  76023. protected _thumbWidth: ValueAndUnit;
  76024. private _minimum;
  76025. private _maximum;
  76026. private _value;
  76027. private _isVertical;
  76028. protected _barOffset: ValueAndUnit;
  76029. private _isThumbClamped;
  76030. protected _displayThumb: boolean;
  76031. private _step;
  76032. private _lastPointerDownID;
  76033. protected _effectiveBarOffset: number;
  76034. protected _renderLeft: number;
  76035. protected _renderTop: number;
  76036. protected _renderWidth: number;
  76037. protected _renderHeight: number;
  76038. protected _backgroundBoxLength: number;
  76039. protected _backgroundBoxThickness: number;
  76040. protected _effectiveThumbThickness: number;
  76041. /** BABYLON.Observable raised when the sldier value changes */
  76042. onValueChangedObservable: BABYLON.Observable<number>;
  76043. /** Gets or sets a boolean indicating if the thumb must be rendered */
  76044. get displayThumb(): boolean;
  76045. set displayThumb(value: boolean);
  76046. /** Gets or sets a step to apply to values (0 by default) */
  76047. get step(): number;
  76048. set step(value: number);
  76049. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  76050. get barOffset(): string | number;
  76051. /** Gets main bar offset in pixels*/
  76052. get barOffsetInPixels(): number;
  76053. set barOffset(value: string | number);
  76054. /** Gets or sets thumb width */
  76055. get thumbWidth(): string | number;
  76056. /** Gets thumb width in pixels */
  76057. get thumbWidthInPixels(): number;
  76058. set thumbWidth(value: string | number);
  76059. /** Gets or sets minimum value */
  76060. get minimum(): number;
  76061. set minimum(value: number);
  76062. /** Gets or sets maximum value */
  76063. get maximum(): number;
  76064. set maximum(value: number);
  76065. /** Gets or sets current value */
  76066. get value(): number;
  76067. set value(value: number);
  76068. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  76069. get isVertical(): boolean;
  76070. set isVertical(value: boolean);
  76071. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  76072. get isThumbClamped(): boolean;
  76073. set isThumbClamped(value: boolean);
  76074. /**
  76075. * Creates a new BaseSlider
  76076. * @param name defines the control name
  76077. */
  76078. constructor(name?: string | undefined);
  76079. protected _getTypeName(): string;
  76080. protected _getThumbPosition(): number;
  76081. protected _getThumbThickness(type: string): number;
  76082. protected _prepareRenderingData(type: string): void;
  76083. private _pointerIsDown;
  76084. /** @hidden */
  76085. protected _updateValueFromPointer(x: number, y: number): void;
  76086. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76087. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76088. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76089. }
  76090. }
  76091. declare module BABYLON.GUI {
  76092. /**
  76093. * Class used to create slider controls
  76094. */
  76095. export class Slider extends BaseSlider {
  76096. name?: string | undefined;
  76097. private _background;
  76098. private _borderColor;
  76099. private _isThumbCircle;
  76100. protected _displayValueBar: boolean;
  76101. /** Gets or sets a boolean indicating if the value bar must be rendered */
  76102. get displayValueBar(): boolean;
  76103. set displayValueBar(value: boolean);
  76104. /** Gets or sets border color */
  76105. get borderColor(): string;
  76106. set borderColor(value: string);
  76107. /** Gets or sets background color */
  76108. get background(): string;
  76109. set background(value: string);
  76110. /** Gets or sets a boolean indicating if the thumb should be round or square */
  76111. get isThumbCircle(): boolean;
  76112. set isThumbCircle(value: boolean);
  76113. /**
  76114. * Creates a new Slider
  76115. * @param name defines the control name
  76116. */
  76117. constructor(name?: string | undefined);
  76118. protected _getTypeName(): string;
  76119. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76120. }
  76121. }
  76122. declare module BABYLON.GUI {
  76123. /** Class used to create a RadioGroup
  76124. * which contains groups of radio buttons
  76125. */
  76126. export class SelectorGroup {
  76127. /** name of SelectorGroup */
  76128. name: string;
  76129. private _groupPanel;
  76130. private _selectors;
  76131. private _groupHeader;
  76132. /**
  76133. * Creates a new SelectorGroup
  76134. * @param name of group, used as a group heading
  76135. */
  76136. constructor(
  76137. /** name of SelectorGroup */
  76138. name: string);
  76139. /** Gets the groupPanel of the SelectorGroup */
  76140. get groupPanel(): StackPanel;
  76141. /** Gets the selectors array */
  76142. get selectors(): StackPanel[];
  76143. /** Gets and sets the group header */
  76144. get header(): string;
  76145. set header(label: string);
  76146. /** @hidden */
  76147. private _addGroupHeader;
  76148. /** @hidden*/
  76149. _getSelector(selectorNb: number): StackPanel | undefined;
  76150. /** Removes the selector at the given position
  76151. * @param selectorNb the position of the selector within the group
  76152. */
  76153. removeSelector(selectorNb: number): void;
  76154. }
  76155. /** Class used to create a CheckboxGroup
  76156. * which contains groups of checkbox buttons
  76157. */
  76158. export class CheckboxGroup extends SelectorGroup {
  76159. /** Adds a checkbox as a control
  76160. * @param text is the label for the selector
  76161. * @param func is the function called when the Selector is checked
  76162. * @param checked is true when Selector is checked
  76163. */
  76164. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  76165. /** @hidden */
  76166. _setSelectorLabel(selectorNb: number, label: string): void;
  76167. /** @hidden */
  76168. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76169. /** @hidden */
  76170. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76171. /** @hidden */
  76172. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76173. }
  76174. /** Class used to create a RadioGroup
  76175. * which contains groups of radio buttons
  76176. */
  76177. export class RadioGroup extends SelectorGroup {
  76178. private _selectNb;
  76179. /** Adds a radio button as a control
  76180. * @param label is the label for the selector
  76181. * @param func is the function called when the Selector is checked
  76182. * @param checked is true when Selector is checked
  76183. */
  76184. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  76185. /** @hidden */
  76186. _setSelectorLabel(selectorNb: number, label: string): void;
  76187. /** @hidden */
  76188. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76189. /** @hidden */
  76190. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76191. /** @hidden */
  76192. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76193. }
  76194. /** Class used to create a SliderGroup
  76195. * which contains groups of slider buttons
  76196. */
  76197. export class SliderGroup extends SelectorGroup {
  76198. /**
  76199. * Adds a slider to the SelectorGroup
  76200. * @param label is the label for the SliderBar
  76201. * @param func is the function called when the Slider moves
  76202. * @param unit is a string describing the units used, eg degrees or metres
  76203. * @param min is the minimum value for the Slider
  76204. * @param max is the maximum value for the Slider
  76205. * @param value is the start value for the Slider between min and max
  76206. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  76207. */
  76208. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  76209. /** @hidden */
  76210. _setSelectorLabel(selectorNb: number, label: string): void;
  76211. /** @hidden */
  76212. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76213. /** @hidden */
  76214. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76215. /** @hidden */
  76216. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76217. }
  76218. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  76219. * @see http://doc.babylonjs.com/how_to/selector
  76220. */
  76221. export class SelectionPanel extends Rectangle {
  76222. /** name of SelectionPanel */
  76223. name: string;
  76224. /** an array of SelectionGroups */
  76225. groups: SelectorGroup[];
  76226. private _panel;
  76227. private _buttonColor;
  76228. private _buttonBackground;
  76229. private _headerColor;
  76230. private _barColor;
  76231. private _barHeight;
  76232. private _spacerHeight;
  76233. private _labelColor;
  76234. private _groups;
  76235. private _bars;
  76236. /**
  76237. * Creates a new SelectionPanel
  76238. * @param name of SelectionPanel
  76239. * @param groups is an array of SelectionGroups
  76240. */
  76241. constructor(
  76242. /** name of SelectionPanel */
  76243. name: string,
  76244. /** an array of SelectionGroups */
  76245. groups?: SelectorGroup[]);
  76246. protected _getTypeName(): string;
  76247. /** Gets or sets the headerColor */
  76248. get headerColor(): string;
  76249. set headerColor(color: string);
  76250. private _setHeaderColor;
  76251. /** Gets or sets the button color */
  76252. get buttonColor(): string;
  76253. set buttonColor(color: string);
  76254. private _setbuttonColor;
  76255. /** Gets or sets the label color */
  76256. get labelColor(): string;
  76257. set labelColor(color: string);
  76258. private _setLabelColor;
  76259. /** Gets or sets the button background */
  76260. get buttonBackground(): string;
  76261. set buttonBackground(color: string);
  76262. private _setButtonBackground;
  76263. /** Gets or sets the color of separator bar */
  76264. get barColor(): string;
  76265. set barColor(color: string);
  76266. private _setBarColor;
  76267. /** Gets or sets the height of separator bar */
  76268. get barHeight(): string;
  76269. set barHeight(value: string);
  76270. private _setBarHeight;
  76271. /** Gets or sets the height of spacers*/
  76272. get spacerHeight(): string;
  76273. set spacerHeight(value: string);
  76274. private _setSpacerHeight;
  76275. /** Adds a bar between groups */
  76276. private _addSpacer;
  76277. /** Add a group to the selection panel
  76278. * @param group is the selector group to add
  76279. */
  76280. addGroup(group: SelectorGroup): void;
  76281. /** Remove the group from the given position
  76282. * @param groupNb is the position of the group in the list
  76283. */
  76284. removeGroup(groupNb: number): void;
  76285. /** Change a group header label
  76286. * @param label is the new group header label
  76287. * @param groupNb is the number of the group to relabel
  76288. * */
  76289. setHeaderName(label: string, groupNb: number): void;
  76290. /** Change selector label to the one given
  76291. * @param label is the new selector label
  76292. * @param groupNb is the number of the groupcontaining the selector
  76293. * @param selectorNb is the number of the selector within a group to relabel
  76294. * */
  76295. relabel(label: string, groupNb: number, selectorNb: number): void;
  76296. /** For a given group position remove the selector at the given position
  76297. * @param groupNb is the number of the group to remove the selector from
  76298. * @param selectorNb is the number of the selector within the group
  76299. */
  76300. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  76301. /** For a given group position of correct type add a checkbox button
  76302. * @param groupNb is the number of the group to remove the selector from
  76303. * @param label is the label for the selector
  76304. * @param func is the function called when the Selector is checked
  76305. * @param checked is true when Selector is checked
  76306. */
  76307. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  76308. /** For a given group position of correct type add a radio button
  76309. * @param groupNb is the number of the group to remove the selector from
  76310. * @param label is the label for the selector
  76311. * @param func is the function called when the Selector is checked
  76312. * @param checked is true when Selector is checked
  76313. */
  76314. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  76315. /**
  76316. * For a given slider group add a slider
  76317. * @param groupNb is the number of the group to add the slider to
  76318. * @param label is the label for the Slider
  76319. * @param func is the function called when the Slider moves
  76320. * @param unit is a string describing the units used, eg degrees or metres
  76321. * @param min is the minimum value for the Slider
  76322. * @param max is the maximum value for the Slider
  76323. * @param value is the start value for the Slider between min and max
  76324. * @param onVal is the function used to format the value displayed, eg radians to degrees
  76325. */
  76326. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  76327. }
  76328. }
  76329. declare module BABYLON.GUI {
  76330. /**
  76331. * Class used to hold a the container for ScrollViewer
  76332. * @hidden
  76333. */
  76334. export class _ScrollViewerWindow extends Container {
  76335. parentClientWidth: number;
  76336. parentClientHeight: number;
  76337. private _freezeControls;
  76338. private _parentMeasure;
  76339. private _oldLeft;
  76340. private _oldTop;
  76341. get freezeControls(): boolean;
  76342. set freezeControls(value: boolean);
  76343. private _bucketWidth;
  76344. private _bucketHeight;
  76345. private _buckets;
  76346. private _bucketLen;
  76347. get bucketWidth(): number;
  76348. get bucketHeight(): number;
  76349. setBucketSizes(width: number, height: number): void;
  76350. private _useBuckets;
  76351. private _makeBuckets;
  76352. private _dispatchInBuckets;
  76353. private _updateMeasures;
  76354. private _updateChildrenMeasures;
  76355. private _restoreMeasures;
  76356. /**
  76357. * Creates a new ScrollViewerWindow
  76358. * @param name of ScrollViewerWindow
  76359. */
  76360. constructor(name?: string);
  76361. protected _getTypeName(): string;
  76362. /** @hidden */
  76363. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76364. /** @hidden */
  76365. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  76366. private _scrollChildren;
  76367. private _scrollChildrenWithBuckets;
  76368. /** @hidden */
  76369. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  76370. protected _postMeasure(): void;
  76371. }
  76372. }
  76373. declare module BABYLON.GUI {
  76374. /**
  76375. * Class used to create slider controls
  76376. */
  76377. export class ScrollBar extends BaseSlider {
  76378. name?: string | undefined;
  76379. private _background;
  76380. private _borderColor;
  76381. private _tempMeasure;
  76382. /** Gets or sets border color */
  76383. get borderColor(): string;
  76384. set borderColor(value: string);
  76385. /** Gets or sets background color */
  76386. get background(): string;
  76387. set background(value: string);
  76388. /**
  76389. * Creates a new Slider
  76390. * @param name defines the control name
  76391. */
  76392. constructor(name?: string | undefined);
  76393. protected _getTypeName(): string;
  76394. protected _getThumbThickness(): number;
  76395. _draw(context: CanvasRenderingContext2D): void;
  76396. private _first;
  76397. private _originX;
  76398. private _originY;
  76399. /** @hidden */
  76400. protected _updateValueFromPointer(x: number, y: number): void;
  76401. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76402. }
  76403. }
  76404. declare module BABYLON.GUI {
  76405. /**
  76406. * Class used to create slider controls
  76407. */
  76408. export class ImageScrollBar extends BaseSlider {
  76409. name?: string | undefined;
  76410. private _backgroundBaseImage;
  76411. private _backgroundImage;
  76412. private _thumbImage;
  76413. private _thumbBaseImage;
  76414. private _thumbLength;
  76415. private _thumbHeight;
  76416. private _barImageHeight;
  76417. private _tempMeasure;
  76418. /** Number of 90° rotation to apply on the images when in vertical mode */
  76419. num90RotationInVerticalMode: number;
  76420. /**
  76421. * Gets or sets the image used to render the background for horizontal bar
  76422. */
  76423. get backgroundImage(): Image;
  76424. set backgroundImage(value: Image);
  76425. /**
  76426. * Gets or sets the image used to render the thumb
  76427. */
  76428. get thumbImage(): Image;
  76429. set thumbImage(value: Image);
  76430. /**
  76431. * Gets or sets the length of the thumb
  76432. */
  76433. get thumbLength(): number;
  76434. set thumbLength(value: number);
  76435. /**
  76436. * Gets or sets the height of the thumb
  76437. */
  76438. get thumbHeight(): number;
  76439. set thumbHeight(value: number);
  76440. /**
  76441. * Gets or sets the height of the bar image
  76442. */
  76443. get barImageHeight(): number;
  76444. set barImageHeight(value: number);
  76445. /**
  76446. * Creates a new ImageScrollBar
  76447. * @param name defines the control name
  76448. */
  76449. constructor(name?: string | undefined);
  76450. protected _getTypeName(): string;
  76451. protected _getThumbThickness(): number;
  76452. _draw(context: CanvasRenderingContext2D): void;
  76453. private _first;
  76454. private _originX;
  76455. private _originY;
  76456. /** @hidden */
  76457. protected _updateValueFromPointer(x: number, y: number): void;
  76458. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76459. }
  76460. }
  76461. declare module BABYLON.GUI {
  76462. /**
  76463. * Class used to hold a viewer window and sliders in a grid
  76464. */
  76465. export class ScrollViewer extends Rectangle {
  76466. private _grid;
  76467. private _horizontalBarSpace;
  76468. private _verticalBarSpace;
  76469. private _dragSpace;
  76470. private _horizontalBar;
  76471. private _verticalBar;
  76472. private _barColor;
  76473. private _barBackground;
  76474. private _barImage;
  76475. private _horizontalBarImage;
  76476. private _verticalBarImage;
  76477. private _barBackgroundImage;
  76478. private _horizontalBarBackgroundImage;
  76479. private _verticalBarBackgroundImage;
  76480. private _barSize;
  76481. private _window;
  76482. private _pointerIsOver;
  76483. private _wheelPrecision;
  76484. private _onWheelObserver;
  76485. private _clientWidth;
  76486. private _clientHeight;
  76487. private _useImageBar;
  76488. private _thumbLength;
  76489. private _thumbHeight;
  76490. private _barImageHeight;
  76491. private _horizontalBarImageHeight;
  76492. private _verticalBarImageHeight;
  76493. private _oldWindowContentsWidth;
  76494. private _oldWindowContentsHeight;
  76495. /**
  76496. * Gets the horizontal scrollbar
  76497. */
  76498. get horizontalBar(): ScrollBar | ImageScrollBar;
  76499. /**
  76500. * Gets the vertical scrollbar
  76501. */
  76502. get verticalBar(): ScrollBar | ImageScrollBar;
  76503. /**
  76504. * Adds a new control to the current container
  76505. * @param control defines the control to add
  76506. * @returns the current container
  76507. */
  76508. addControl(control: BABYLON.Nullable<Control>): Container;
  76509. /**
  76510. * Removes a control from the current container
  76511. * @param control defines the control to remove
  76512. * @returns the current container
  76513. */
  76514. removeControl(control: Control): Container;
  76515. /** Gets the list of children */
  76516. get children(): Control[];
  76517. _flagDescendantsAsMatrixDirty(): void;
  76518. /**
  76519. * Freezes or unfreezes the controls in the window.
  76520. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  76521. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  76522. */
  76523. get freezeControls(): boolean;
  76524. set freezeControls(value: boolean);
  76525. /** Gets the bucket width */
  76526. get bucketWidth(): number;
  76527. /** Gets the bucket height */
  76528. get bucketHeight(): number;
  76529. /**
  76530. * Sets the bucket sizes.
  76531. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  76532. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  76533. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  76534. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  76535. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  76536. * used), that's why it is not enabled by default.
  76537. * @param width width of the bucket
  76538. * @param height height of the bucket
  76539. */
  76540. setBucketSizes(width: number, height: number): void;
  76541. private _forceHorizontalBar;
  76542. private _forceVerticalBar;
  76543. /**
  76544. * Forces the horizontal scroll bar to be displayed
  76545. */
  76546. get forceHorizontalBar(): boolean;
  76547. set forceHorizontalBar(value: boolean);
  76548. /**
  76549. * Forces the vertical scroll bar to be displayed
  76550. */
  76551. get forceVerticalBar(): boolean;
  76552. set forceVerticalBar(value: boolean);
  76553. /**
  76554. * Creates a new ScrollViewer
  76555. * @param name of ScrollViewer
  76556. */
  76557. constructor(name?: string, isImageBased?: boolean);
  76558. /** Reset the scroll viewer window to initial size */
  76559. resetWindow(): void;
  76560. protected _getTypeName(): string;
  76561. private _buildClientSizes;
  76562. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76563. protected _postMeasure(): void;
  76564. /**
  76565. * Gets or sets the mouse wheel precision
  76566. * from 0 to 1 with a default value of 0.05
  76567. * */
  76568. get wheelPrecision(): number;
  76569. set wheelPrecision(value: number);
  76570. /** Gets or sets the scroll bar container background color */
  76571. get scrollBackground(): string;
  76572. set scrollBackground(color: string);
  76573. /** Gets or sets the bar color */
  76574. get barColor(): string;
  76575. set barColor(color: string);
  76576. /** Gets or sets the bar image */
  76577. get thumbImage(): Image;
  76578. set thumbImage(value: Image);
  76579. /** Gets or sets the horizontal bar image */
  76580. get horizontalThumbImage(): Image;
  76581. set horizontalThumbImage(value: Image);
  76582. /** Gets or sets the vertical bar image */
  76583. get verticalThumbImage(): Image;
  76584. set verticalThumbImage(value: Image);
  76585. /** Gets or sets the size of the bar */
  76586. get barSize(): number;
  76587. set barSize(value: number);
  76588. /** Gets or sets the length of the thumb */
  76589. get thumbLength(): number;
  76590. set thumbLength(value: number);
  76591. /** Gets or sets the height of the thumb */
  76592. get thumbHeight(): number;
  76593. set thumbHeight(value: number);
  76594. /** Gets or sets the height of the bar image */
  76595. get barImageHeight(): number;
  76596. set barImageHeight(value: number);
  76597. /** Gets or sets the height of the horizontal bar image */
  76598. get horizontalBarImageHeight(): number;
  76599. set horizontalBarImageHeight(value: number);
  76600. /** Gets or sets the height of the vertical bar image */
  76601. get verticalBarImageHeight(): number;
  76602. set verticalBarImageHeight(value: number);
  76603. /** Gets or sets the bar background */
  76604. get barBackground(): string;
  76605. set barBackground(color: string);
  76606. /** Gets or sets the bar background image */
  76607. get barImage(): Image;
  76608. set barImage(value: Image);
  76609. /** Gets or sets the horizontal bar background image */
  76610. get horizontalBarImage(): Image;
  76611. set horizontalBarImage(value: Image);
  76612. /** Gets or sets the vertical bar background image */
  76613. get verticalBarImage(): Image;
  76614. set verticalBarImage(value: Image);
  76615. private _setWindowPosition;
  76616. /** @hidden */
  76617. private _updateScroller;
  76618. _link(host: AdvancedDynamicTexture): void;
  76619. /** @hidden */
  76620. private _addBar;
  76621. /** @hidden */
  76622. private _attachWheel;
  76623. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  76624. /** Releases associated resources */
  76625. dispose(): void;
  76626. }
  76627. }
  76628. declare module BABYLON.GUI {
  76629. /** Class used to render a grid */
  76630. export class DisplayGrid extends Control {
  76631. name?: string | undefined;
  76632. private _cellWidth;
  76633. private _cellHeight;
  76634. private _minorLineTickness;
  76635. private _minorLineColor;
  76636. private _majorLineTickness;
  76637. private _majorLineColor;
  76638. private _majorLineFrequency;
  76639. private _background;
  76640. private _displayMajorLines;
  76641. private _displayMinorLines;
  76642. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  76643. get displayMinorLines(): boolean;
  76644. set displayMinorLines(value: boolean);
  76645. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  76646. get displayMajorLines(): boolean;
  76647. set displayMajorLines(value: boolean);
  76648. /** Gets or sets background color (Black by default) */
  76649. get background(): string;
  76650. set background(value: string);
  76651. /** Gets or sets the width of each cell (20 by default) */
  76652. get cellWidth(): number;
  76653. set cellWidth(value: number);
  76654. /** Gets or sets the height of each cell (20 by default) */
  76655. get cellHeight(): number;
  76656. set cellHeight(value: number);
  76657. /** Gets or sets the tickness of minor lines (1 by default) */
  76658. get minorLineTickness(): number;
  76659. set minorLineTickness(value: number);
  76660. /** Gets or sets the color of minor lines (DarkGray by default) */
  76661. get minorLineColor(): string;
  76662. set minorLineColor(value: string);
  76663. /** Gets or sets the tickness of major lines (2 by default) */
  76664. get majorLineTickness(): number;
  76665. set majorLineTickness(value: number);
  76666. /** Gets or sets the color of major lines (White by default) */
  76667. get majorLineColor(): string;
  76668. set majorLineColor(value: string);
  76669. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  76670. get majorLineFrequency(): number;
  76671. set majorLineFrequency(value: number);
  76672. /**
  76673. * Creates a new GridDisplayRectangle
  76674. * @param name defines the control name
  76675. */
  76676. constructor(name?: string | undefined);
  76677. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76678. protected _getTypeName(): string;
  76679. }
  76680. }
  76681. declare module BABYLON.GUI {
  76682. /**
  76683. * Class used to create slider controls based on images
  76684. */
  76685. export class ImageBasedSlider extends BaseSlider {
  76686. name?: string | undefined;
  76687. private _backgroundImage;
  76688. private _thumbImage;
  76689. private _valueBarImage;
  76690. private _tempMeasure;
  76691. get displayThumb(): boolean;
  76692. set displayThumb(value: boolean);
  76693. /**
  76694. * Gets or sets the image used to render the background
  76695. */
  76696. get backgroundImage(): Image;
  76697. set backgroundImage(value: Image);
  76698. /**
  76699. * Gets or sets the image used to render the value bar
  76700. */
  76701. get valueBarImage(): Image;
  76702. set valueBarImage(value: Image);
  76703. /**
  76704. * Gets or sets the image used to render the thumb
  76705. */
  76706. get thumbImage(): Image;
  76707. set thumbImage(value: Image);
  76708. /**
  76709. * Creates a new ImageBasedSlider
  76710. * @param name defines the control name
  76711. */
  76712. constructor(name?: string | undefined);
  76713. protected _getTypeName(): string;
  76714. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76715. }
  76716. }
  76717. declare module BABYLON.GUI {
  76718. /**
  76719. * Forcing an export so that this code will execute
  76720. * @hidden
  76721. */
  76722. const name = "Statics";
  76723. }
  76724. declare module BABYLON.GUI {
  76725. /**
  76726. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  76727. */
  76728. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  76729. /**
  76730. * Define the instrumented AdvancedDynamicTexture.
  76731. */
  76732. texture: AdvancedDynamicTexture;
  76733. private _captureRenderTime;
  76734. private _renderTime;
  76735. private _captureLayoutTime;
  76736. private _layoutTime;
  76737. private _onBeginRenderObserver;
  76738. private _onEndRenderObserver;
  76739. private _onBeginLayoutObserver;
  76740. private _onEndLayoutObserver;
  76741. /**
  76742. * Gets the perf counter used to capture render time
  76743. */
  76744. get renderTimeCounter(): BABYLON.PerfCounter;
  76745. /**
  76746. * Gets the perf counter used to capture layout time
  76747. */
  76748. get layoutTimeCounter(): BABYLON.PerfCounter;
  76749. /**
  76750. * Enable or disable the render time capture
  76751. */
  76752. get captureRenderTime(): boolean;
  76753. set captureRenderTime(value: boolean);
  76754. /**
  76755. * Enable or disable the layout time capture
  76756. */
  76757. get captureLayoutTime(): boolean;
  76758. set captureLayoutTime(value: boolean);
  76759. /**
  76760. * Instantiates a new advanced dynamic texture instrumentation.
  76761. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  76762. * @param texture Defines the AdvancedDynamicTexture to instrument
  76763. */
  76764. constructor(
  76765. /**
  76766. * Define the instrumented AdvancedDynamicTexture.
  76767. */
  76768. texture: AdvancedDynamicTexture);
  76769. /**
  76770. * Dispose and release associated resources.
  76771. */
  76772. dispose(): void;
  76773. }
  76774. }
  76775. declare module BABYLON.GUI {
  76776. /**
  76777. * Class used to load GUI via XML.
  76778. */
  76779. export class XmlLoader {
  76780. private _nodes;
  76781. private _nodeTypes;
  76782. private _isLoaded;
  76783. private _objectAttributes;
  76784. private _parentClass;
  76785. /**
  76786. * Create a new xml loader
  76787. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  76788. */
  76789. constructor(parentClass?: null);
  76790. private _getChainElement;
  76791. private _getClassAttribute;
  76792. private _createGuiElement;
  76793. private _parseGrid;
  76794. private _parseElement;
  76795. private _prepareSourceElement;
  76796. private _parseElementsFromSource;
  76797. private _parseXml;
  76798. /**
  76799. * Gets if the loading has finished.
  76800. * @returns whether the loading has finished or not
  76801. */
  76802. isLoaded(): boolean;
  76803. /**
  76804. * Gets a loaded node / control by id.
  76805. * @param id the Controls id set in the xml
  76806. * @returns element of type Control
  76807. */
  76808. getNodeById(id: string): any;
  76809. /**
  76810. * Gets all loaded nodes / controls
  76811. * @returns Array of controls
  76812. */
  76813. getNodes(): any;
  76814. /**
  76815. * Initiates the xml layout loading
  76816. * @param xmlFile defines the xml layout to load
  76817. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  76818. * @param callback defines the callback called on layout load.
  76819. */
  76820. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  76821. }
  76822. }
  76823. declare module BABYLON.GUI {
  76824. /**
  76825. * Class used to create containers for controls
  76826. */
  76827. export class Container3D extends Control3D {
  76828. private _blockLayout;
  76829. /**
  76830. * Gets the list of child controls
  76831. */
  76832. protected _children: Control3D[];
  76833. /**
  76834. * Gets the list of child controls
  76835. */
  76836. get children(): Array<Control3D>;
  76837. /**
  76838. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  76839. * This is helpful to optimize layout operation when adding multiple children in a row
  76840. */
  76841. get blockLayout(): boolean;
  76842. set blockLayout(value: boolean);
  76843. /**
  76844. * Creates a new container
  76845. * @param name defines the container name
  76846. */
  76847. constructor(name?: string);
  76848. /**
  76849. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  76850. * @returns the current container
  76851. */
  76852. updateLayout(): Container3D;
  76853. /**
  76854. * Gets a boolean indicating if the given control is in the children of this control
  76855. * @param control defines the control to check
  76856. * @returns true if the control is in the child list
  76857. */
  76858. containsControl(control: Control3D): boolean;
  76859. /**
  76860. * Adds a control to the children of this control
  76861. * @param control defines the control to add
  76862. * @returns the current container
  76863. */
  76864. addControl(control: Control3D): Container3D;
  76865. /**
  76866. * This function will be called everytime a new control is added
  76867. */
  76868. protected _arrangeChildren(): void;
  76869. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  76870. /**
  76871. * Removes a control from the children of this control
  76872. * @param control defines the control to remove
  76873. * @returns the current container
  76874. */
  76875. removeControl(control: Control3D): Container3D;
  76876. protected _getTypeName(): string;
  76877. /**
  76878. * Releases all associated resources
  76879. */
  76880. dispose(): void;
  76881. /** Control rotation will remain unchanged */
  76882. static readonly UNSET_ORIENTATION: number;
  76883. /** Control will rotate to make it look at sphere central axis */
  76884. static readonly FACEORIGIN_ORIENTATION: number;
  76885. /** Control will rotate to make it look back at sphere central axis */
  76886. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  76887. /** Control will rotate to look at z axis (0, 0, 1) */
  76888. static readonly FACEFORWARD_ORIENTATION: number;
  76889. /** Control will rotate to look at negative z axis (0, 0, -1) */
  76890. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  76891. }
  76892. }
  76893. declare module BABYLON.GUI {
  76894. /**
  76895. * Class used to manage 3D user interface
  76896. * @see http://doc.babylonjs.com/how_to/gui3d
  76897. */
  76898. export class GUI3DManager implements BABYLON.IDisposable {
  76899. private _scene;
  76900. private _sceneDisposeObserver;
  76901. private _utilityLayer;
  76902. private _rootContainer;
  76903. private _pointerObserver;
  76904. private _pointerOutObserver;
  76905. /** @hidden */
  76906. _lastPickedControl: Control3D;
  76907. /** @hidden */
  76908. _lastControlOver: {
  76909. [pointerId: number]: Control3D;
  76910. };
  76911. /** @hidden */
  76912. _lastControlDown: {
  76913. [pointerId: number]: Control3D;
  76914. };
  76915. /**
  76916. * BABYLON.Observable raised when the point picked by the pointer events changed
  76917. */
  76918. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  76919. /** @hidden */
  76920. _sharedMaterials: {
  76921. [key: string]: BABYLON.Material;
  76922. };
  76923. /** Gets the hosting scene */
  76924. get scene(): BABYLON.Scene;
  76925. /** Gets associated utility layer */
  76926. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  76927. /**
  76928. * Creates a new GUI3DManager
  76929. * @param scene
  76930. */
  76931. constructor(scene?: BABYLON.Scene);
  76932. private _handlePointerOut;
  76933. private _doPicking;
  76934. /**
  76935. * Gets the root container
  76936. */
  76937. get rootContainer(): Container3D;
  76938. /**
  76939. * Gets a boolean indicating if the given control is in the root child list
  76940. * @param control defines the control to check
  76941. * @returns true if the control is in the root child list
  76942. */
  76943. containsControl(control: Control3D): boolean;
  76944. /**
  76945. * Adds a control to the root child list
  76946. * @param control defines the control to add
  76947. * @returns the current manager
  76948. */
  76949. addControl(control: Control3D): GUI3DManager;
  76950. /**
  76951. * Removes a control from the root child list
  76952. * @param control defines the control to remove
  76953. * @returns the current container
  76954. */
  76955. removeControl(control: Control3D): GUI3DManager;
  76956. /**
  76957. * Releases all associated resources
  76958. */
  76959. dispose(): void;
  76960. }
  76961. }
  76962. declare module BABYLON.GUI {
  76963. /**
  76964. * Class used to transport BABYLON.Vector3 information for pointer events
  76965. */
  76966. export class Vector3WithInfo extends BABYLON.Vector3 {
  76967. /** defines the current mouse button index */
  76968. buttonIndex: number;
  76969. /**
  76970. * Creates a new Vector3WithInfo
  76971. * @param source defines the vector3 data to transport
  76972. * @param buttonIndex defines the current mouse button index
  76973. */
  76974. constructor(source: BABYLON.Vector3,
  76975. /** defines the current mouse button index */
  76976. buttonIndex?: number);
  76977. }
  76978. }
  76979. declare module BABYLON.GUI {
  76980. /**
  76981. * Class used as base class for controls
  76982. */
  76983. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  76984. /** Defines the control name */
  76985. name?: string | undefined;
  76986. /** @hidden */
  76987. _host: GUI3DManager;
  76988. private _node;
  76989. private _downCount;
  76990. private _enterCount;
  76991. private _downPointerIds;
  76992. private _isVisible;
  76993. /** Gets or sets the control position in world space */
  76994. get position(): BABYLON.Vector3;
  76995. set position(value: BABYLON.Vector3);
  76996. /** Gets or sets the control scaling in world space */
  76997. get scaling(): BABYLON.Vector3;
  76998. set scaling(value: BABYLON.Vector3);
  76999. /** Callback used to start pointer enter animation */
  77000. pointerEnterAnimation: () => void;
  77001. /** Callback used to start pointer out animation */
  77002. pointerOutAnimation: () => void;
  77003. /** Callback used to start pointer down animation */
  77004. pointerDownAnimation: () => void;
  77005. /** Callback used to start pointer up animation */
  77006. pointerUpAnimation: () => void;
  77007. /**
  77008. * An event triggered when the pointer move over the control
  77009. */
  77010. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  77011. /**
  77012. * An event triggered when the pointer move out of the control
  77013. */
  77014. onPointerOutObservable: BABYLON.Observable<Control3D>;
  77015. /**
  77016. * An event triggered when the pointer taps the control
  77017. */
  77018. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  77019. /**
  77020. * An event triggered when pointer is up
  77021. */
  77022. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  77023. /**
  77024. * An event triggered when a control is clicked on (with a mouse)
  77025. */
  77026. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  77027. /**
  77028. * An event triggered when pointer enters the control
  77029. */
  77030. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  77031. /**
  77032. * Gets or sets the parent container
  77033. */
  77034. parent: BABYLON.Nullable<Container3D>;
  77035. private _behaviors;
  77036. /**
  77037. * Gets the list of attached behaviors
  77038. * @see http://doc.babylonjs.com/features/behaviour
  77039. */
  77040. get behaviors(): BABYLON.Behavior<Control3D>[];
  77041. /**
  77042. * Attach a behavior to the control
  77043. * @see http://doc.babylonjs.com/features/behaviour
  77044. * @param behavior defines the behavior to attach
  77045. * @returns the current control
  77046. */
  77047. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  77048. /**
  77049. * Remove an attached behavior
  77050. * @see http://doc.babylonjs.com/features/behaviour
  77051. * @param behavior defines the behavior to attach
  77052. * @returns the current control
  77053. */
  77054. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  77055. /**
  77056. * Gets an attached behavior by name
  77057. * @param name defines the name of the behavior to look for
  77058. * @see http://doc.babylonjs.com/features/behaviour
  77059. * @returns null if behavior was not found else the requested behavior
  77060. */
  77061. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  77062. /** Gets or sets a boolean indicating if the control is visible */
  77063. get isVisible(): boolean;
  77064. set isVisible(value: boolean);
  77065. /**
  77066. * Creates a new control
  77067. * @param name defines the control name
  77068. */
  77069. constructor(
  77070. /** Defines the control name */
  77071. name?: string | undefined);
  77072. /**
  77073. * Gets a string representing the class name
  77074. */
  77075. get typeName(): string;
  77076. /**
  77077. * Get the current class name of the control.
  77078. * @returns current class name
  77079. */
  77080. getClassName(): string;
  77081. protected _getTypeName(): string;
  77082. /**
  77083. * Gets the transform node used by this control
  77084. */
  77085. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  77086. /**
  77087. * Gets the mesh used to render this control
  77088. */
  77089. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  77090. /**
  77091. * Link the control as child of the given node
  77092. * @param node defines the node to link to. Use null to unlink the control
  77093. * @returns the current control
  77094. */
  77095. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  77096. /** @hidden **/
  77097. _prepareNode(scene: BABYLON.Scene): void;
  77098. /**
  77099. * Node creation.
  77100. * Can be overriden by children
  77101. * @param scene defines the scene where the node must be attached
  77102. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  77103. */
  77104. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  77105. /**
  77106. * Affect a material to the given mesh
  77107. * @param mesh defines the mesh which will represent the control
  77108. */
  77109. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  77110. /** @hidden */
  77111. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  77112. /** @hidden */
  77113. _onPointerEnter(target: Control3D): boolean;
  77114. /** @hidden */
  77115. _onPointerOut(target: Control3D): void;
  77116. /** @hidden */
  77117. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  77118. /** @hidden */
  77119. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77120. /** @hidden */
  77121. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  77122. /** @hidden */
  77123. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  77124. /** @hidden */
  77125. _disposeNode(): void;
  77126. /**
  77127. * Releases all associated resources
  77128. */
  77129. dispose(): void;
  77130. }
  77131. }
  77132. declare module BABYLON.GUI {
  77133. /**
  77134. * Class used as a root to all buttons
  77135. */
  77136. export class AbstractButton3D extends Control3D {
  77137. /**
  77138. * Creates a new button
  77139. * @param name defines the control name
  77140. */
  77141. constructor(name?: string);
  77142. protected _getTypeName(): string;
  77143. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77144. }
  77145. }
  77146. declare module BABYLON.GUI {
  77147. /**
  77148. * Class used to create a button in 3D
  77149. */
  77150. export class Button3D extends AbstractButton3D {
  77151. /** @hidden */
  77152. protected _currentMaterial: BABYLON.Material;
  77153. private _facadeTexture;
  77154. private _content;
  77155. private _contentResolution;
  77156. private _contentScaleRatio;
  77157. /**
  77158. * Gets or sets the texture resolution used to render content (512 by default)
  77159. */
  77160. get contentResolution(): BABYLON.int;
  77161. set contentResolution(value: BABYLON.int);
  77162. /**
  77163. * Gets or sets the texture scale ratio used to render content (2 by default)
  77164. */
  77165. get contentScaleRatio(): number;
  77166. set contentScaleRatio(value: number);
  77167. protected _disposeFacadeTexture(): void;
  77168. protected _resetContent(): void;
  77169. /**
  77170. * Creates a new button
  77171. * @param name defines the control name
  77172. */
  77173. constructor(name?: string);
  77174. /**
  77175. * Gets or sets the GUI 2D content used to display the button's facade
  77176. */
  77177. get content(): Control;
  77178. set content(value: Control);
  77179. /**
  77180. * Apply the facade texture (created from the content property).
  77181. * This function can be overloaded by child classes
  77182. * @param facadeTexture defines the AdvancedDynamicTexture to use
  77183. */
  77184. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  77185. protected _getTypeName(): string;
  77186. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77187. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  77188. /**
  77189. * Releases all associated resources
  77190. */
  77191. dispose(): void;
  77192. }
  77193. }
  77194. declare module BABYLON.GUI {
  77195. /**
  77196. * Abstract class used to create a container panel deployed on the surface of a volume
  77197. */
  77198. export abstract class VolumeBasedPanel extends Container3D {
  77199. private _columns;
  77200. private _rows;
  77201. private _rowThenColum;
  77202. private _orientation;
  77203. protected _cellWidth: number;
  77204. protected _cellHeight: number;
  77205. /**
  77206. * Gets or sets the distance between elements
  77207. */
  77208. margin: number;
  77209. /**
  77210. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  77211. * | Value | Type | Description |
  77212. * | ----- | ----------------------------------- | ----------- |
  77213. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  77214. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  77215. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  77216. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  77217. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  77218. */
  77219. get orientation(): number;
  77220. set orientation(value: number);
  77221. /**
  77222. * Gets or sets the number of columns requested (10 by default).
  77223. * The panel will automatically compute the number of rows based on number of child controls.
  77224. */
  77225. get columns(): BABYLON.int;
  77226. set columns(value: BABYLON.int);
  77227. /**
  77228. * Gets or sets a the number of rows requested.
  77229. * The panel will automatically compute the number of columns based on number of child controls.
  77230. */
  77231. get rows(): BABYLON.int;
  77232. set rows(value: BABYLON.int);
  77233. /**
  77234. * Creates new VolumeBasedPanel
  77235. */
  77236. constructor();
  77237. protected _arrangeChildren(): void;
  77238. /** Child classes must implement this function to provide correct control positioning */
  77239. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77240. /** Child classes can implement this function to provide additional processing */
  77241. protected _finalProcessing(): void;
  77242. }
  77243. }
  77244. declare module BABYLON.GUI {
  77245. /**
  77246. * Class used to create a container panel deployed on the surface of a cylinder
  77247. */
  77248. export class CylinderPanel extends VolumeBasedPanel {
  77249. private _radius;
  77250. /**
  77251. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  77252. */
  77253. get radius(): BABYLON.float;
  77254. set radius(value: BABYLON.float);
  77255. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77256. private _cylindricalMapping;
  77257. }
  77258. }
  77259. declare module BABYLON.GUI {
  77260. /** @hidden */
  77261. export var fluentVertexShader: {
  77262. name: string;
  77263. shader: string;
  77264. };
  77265. }
  77266. declare module BABYLON.GUI {
  77267. /** @hidden */
  77268. export var fluentPixelShader: {
  77269. name: string;
  77270. shader: string;
  77271. };
  77272. }
  77273. declare module BABYLON.GUI {
  77274. /** @hidden */
  77275. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  77276. INNERGLOW: boolean;
  77277. BORDER: boolean;
  77278. HOVERLIGHT: boolean;
  77279. TEXTURE: boolean;
  77280. constructor();
  77281. }
  77282. /**
  77283. * Class used to render controls with fluent desgin
  77284. */
  77285. export class FluentMaterial extends BABYLON.PushMaterial {
  77286. /**
  77287. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  77288. */
  77289. innerGlowColorIntensity: number;
  77290. /**
  77291. * Gets or sets the inner glow color (white by default)
  77292. */
  77293. innerGlowColor: BABYLON.Color3;
  77294. /**
  77295. * Gets or sets alpha value (default is 1.0)
  77296. */
  77297. alpha: number;
  77298. /**
  77299. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  77300. */
  77301. albedoColor: BABYLON.Color3;
  77302. /**
  77303. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  77304. */
  77305. renderBorders: boolean;
  77306. /**
  77307. * Gets or sets border width (default is 0.5)
  77308. */
  77309. borderWidth: number;
  77310. /**
  77311. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  77312. */
  77313. edgeSmoothingValue: number;
  77314. /**
  77315. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  77316. */
  77317. borderMinValue: number;
  77318. /**
  77319. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  77320. */
  77321. renderHoverLight: boolean;
  77322. /**
  77323. * Gets or sets the radius used to render the hover light (default is 1.0)
  77324. */
  77325. hoverRadius: number;
  77326. /**
  77327. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  77328. */
  77329. hoverColor: BABYLON.Color4;
  77330. /**
  77331. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  77332. */
  77333. hoverPosition: BABYLON.Vector3;
  77334. private _albedoTexture;
  77335. /** Gets or sets the texture to use for albedo color */
  77336. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  77337. /**
  77338. * Creates a new Fluent material
  77339. * @param name defines the name of the material
  77340. * @param scene defines the hosting scene
  77341. */
  77342. constructor(name: string, scene: BABYLON.Scene);
  77343. needAlphaBlending(): boolean;
  77344. needAlphaTesting(): boolean;
  77345. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  77346. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  77347. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  77348. getActiveTextures(): BABYLON.BaseTexture[];
  77349. hasTexture(texture: BABYLON.BaseTexture): boolean;
  77350. dispose(forceDisposeEffect?: boolean): void;
  77351. clone(name: string): FluentMaterial;
  77352. serialize(): any;
  77353. getClassName(): string;
  77354. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  77355. }
  77356. }
  77357. declare module BABYLON.GUI {
  77358. /**
  77359. * Class used to create a holographic button in 3D
  77360. */
  77361. export class HolographicButton extends Button3D {
  77362. private _backPlate;
  77363. private _textPlate;
  77364. private _frontPlate;
  77365. private _text;
  77366. private _imageUrl;
  77367. private _shareMaterials;
  77368. private _frontMaterial;
  77369. private _backMaterial;
  77370. private _plateMaterial;
  77371. private _pickedPointObserver;
  77372. private _tooltipFade;
  77373. private _tooltipTextBlock;
  77374. private _tooltipTexture;
  77375. private _tooltipMesh;
  77376. private _tooltipHoverObserver;
  77377. private _tooltipOutObserver;
  77378. private _disposeTooltip;
  77379. /**
  77380. * Rendering ground id of all the mesh in the button
  77381. */
  77382. set renderingGroupId(id: number);
  77383. get renderingGroupId(): number;
  77384. /**
  77385. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  77386. */
  77387. set tooltipText(text: BABYLON.Nullable<string>);
  77388. get tooltipText(): BABYLON.Nullable<string>;
  77389. /**
  77390. * Gets or sets text for the button
  77391. */
  77392. get text(): string;
  77393. set text(value: string);
  77394. /**
  77395. * Gets or sets the image url for the button
  77396. */
  77397. get imageUrl(): string;
  77398. set imageUrl(value: string);
  77399. /**
  77400. * Gets the back material used by this button
  77401. */
  77402. get backMaterial(): FluentMaterial;
  77403. /**
  77404. * Gets the front material used by this button
  77405. */
  77406. get frontMaterial(): FluentMaterial;
  77407. /**
  77408. * Gets the plate material used by this button
  77409. */
  77410. get plateMaterial(): BABYLON.StandardMaterial;
  77411. /**
  77412. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  77413. */
  77414. get shareMaterials(): boolean;
  77415. /**
  77416. * Creates a new button
  77417. * @param name defines the control name
  77418. */
  77419. constructor(name?: string, shareMaterials?: boolean);
  77420. protected _getTypeName(): string;
  77421. private _rebuildContent;
  77422. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77423. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  77424. private _createBackMaterial;
  77425. private _createFrontMaterial;
  77426. private _createPlateMaterial;
  77427. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  77428. /**
  77429. * Releases all associated resources
  77430. */
  77431. dispose(): void;
  77432. }
  77433. }
  77434. declare module BABYLON.GUI {
  77435. /**
  77436. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  77437. */
  77438. export class MeshButton3D extends Button3D {
  77439. /** @hidden */
  77440. protected _currentMesh: BABYLON.Mesh;
  77441. /**
  77442. * Creates a new 3D button based on a mesh
  77443. * @param mesh mesh to become a 3D button
  77444. * @param name defines the control name
  77445. */
  77446. constructor(mesh: BABYLON.Mesh, name?: string);
  77447. protected _getTypeName(): string;
  77448. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77449. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  77450. }
  77451. }
  77452. declare module BABYLON.GUI {
  77453. /**
  77454. * Class used to create a container panel deployed on the surface of a plane
  77455. */
  77456. export class PlanePanel extends VolumeBasedPanel {
  77457. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77458. }
  77459. }
  77460. declare module BABYLON.GUI {
  77461. /**
  77462. * Class used to create a container panel where items get randomized planar mapping
  77463. */
  77464. export class ScatterPanel extends VolumeBasedPanel {
  77465. private _iteration;
  77466. /**
  77467. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  77468. */
  77469. get iteration(): BABYLON.float;
  77470. set iteration(value: BABYLON.float);
  77471. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77472. private _scatterMapping;
  77473. protected _finalProcessing(): void;
  77474. }
  77475. }
  77476. declare module BABYLON.GUI {
  77477. /**
  77478. * Class used to create a container panel deployed on the surface of a sphere
  77479. */
  77480. export class SpherePanel extends VolumeBasedPanel {
  77481. private _radius;
  77482. /**
  77483. * Gets or sets the radius of the sphere where to project controls (5 by default)
  77484. */
  77485. get radius(): BABYLON.float;
  77486. set radius(value: BABYLON.float);
  77487. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77488. private _sphericalMapping;
  77489. }
  77490. }
  77491. declare module BABYLON.GUI {
  77492. /**
  77493. * Class used to create a stack panel in 3D on XY plane
  77494. */
  77495. export class StackPanel3D extends Container3D {
  77496. private _isVertical;
  77497. /**
  77498. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  77499. */
  77500. get isVertical(): boolean;
  77501. set isVertical(value: boolean);
  77502. /**
  77503. * Gets or sets the distance between elements
  77504. */
  77505. margin: number;
  77506. /**
  77507. * Creates new StackPanel
  77508. * @param isVertical
  77509. */
  77510. constructor(isVertical?: boolean);
  77511. protected _arrangeChildren(): void;
  77512. }
  77513. }
  77514. declare module BABYLON {
  77515. /**
  77516. * Configuration for glTF validation
  77517. */
  77518. export interface IGLTFValidationConfiguration {
  77519. /**
  77520. * The url of the glTF validator.
  77521. */
  77522. url: string;
  77523. }
  77524. /**
  77525. * glTF validation
  77526. */
  77527. export class GLTFValidation {
  77528. /**
  77529. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  77530. */
  77531. static Configuration: IGLTFValidationConfiguration;
  77532. private static _LoadScriptPromise;
  77533. /**
  77534. * Validate a glTF asset using the glTF-Validator.
  77535. * @param data The JSON of a glTF or the array buffer of a binary glTF
  77536. * @param rootUrl The root url for the glTF
  77537. * @param fileName The file name for the glTF
  77538. * @param getExternalResource The callback to get external resources for the glTF validator
  77539. * @returns A promise that resolves with the glTF validation results once complete
  77540. */
  77541. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  77542. }
  77543. }
  77544. declare module BABYLON {
  77545. /**
  77546. * Mode that determines the coordinate system to use.
  77547. */
  77548. export enum GLTFLoaderCoordinateSystemMode {
  77549. /**
  77550. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  77551. */
  77552. AUTO = 0,
  77553. /**
  77554. * Sets the useRightHandedSystem flag on the scene.
  77555. */
  77556. FORCE_RIGHT_HANDED = 1
  77557. }
  77558. /**
  77559. * Mode that determines what animations will start.
  77560. */
  77561. export enum GLTFLoaderAnimationStartMode {
  77562. /**
  77563. * No animation will start.
  77564. */
  77565. NONE = 0,
  77566. /**
  77567. * The first animation will start.
  77568. */
  77569. FIRST = 1,
  77570. /**
  77571. * All animations will start.
  77572. */
  77573. ALL = 2
  77574. }
  77575. /**
  77576. * Interface that contains the data for the glTF asset.
  77577. */
  77578. export interface IGLTFLoaderData {
  77579. /**
  77580. * The object that represents the glTF JSON.
  77581. */
  77582. json: Object;
  77583. /**
  77584. * The BIN chunk of a binary glTF.
  77585. */
  77586. bin: Nullable<IDataBuffer>;
  77587. }
  77588. /**
  77589. * Interface for extending the loader.
  77590. */
  77591. export interface IGLTFLoaderExtension {
  77592. /**
  77593. * The name of this extension.
  77594. */
  77595. readonly name: string;
  77596. /**
  77597. * Defines whether this extension is enabled.
  77598. */
  77599. enabled: boolean;
  77600. /**
  77601. * Defines the order of this extension.
  77602. * The loader sorts the extensions using these values when loading.
  77603. */
  77604. order?: number;
  77605. }
  77606. /**
  77607. * Loader state.
  77608. */
  77609. export enum GLTFLoaderState {
  77610. /**
  77611. * The asset is loading.
  77612. */
  77613. LOADING = 0,
  77614. /**
  77615. * The asset is ready for rendering.
  77616. */
  77617. READY = 1,
  77618. /**
  77619. * The asset is completely loaded.
  77620. */
  77621. COMPLETE = 2
  77622. }
  77623. /** @hidden */
  77624. export interface IImportMeshAsyncOutput {
  77625. meshes: AbstractMesh[];
  77626. particleSystems: IParticleSystem[];
  77627. skeletons: Skeleton[];
  77628. animationGroups: AnimationGroup[];
  77629. lights: Light[];
  77630. transformNodes: TransformNode[];
  77631. }
  77632. /** @hidden */
  77633. export interface IGLTFLoader extends IDisposable {
  77634. readonly state: Nullable<GLTFLoaderState>;
  77635. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  77636. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  77637. }
  77638. /**
  77639. * File loader for loading glTF files into a scene.
  77640. */
  77641. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  77642. /** @hidden */
  77643. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  77644. /** @hidden */
  77645. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  77646. /**
  77647. * Raised when the asset has been parsed
  77648. */
  77649. onParsedObservable: Observable<IGLTFLoaderData>;
  77650. private _onParsedObserver;
  77651. /**
  77652. * Raised when the asset has been parsed
  77653. */
  77654. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  77655. /**
  77656. * 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.
  77657. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  77658. * Defaults to true.
  77659. * @hidden
  77660. */
  77661. static IncrementalLoading: boolean;
  77662. /**
  77663. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  77664. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  77665. * @hidden
  77666. */
  77667. static HomogeneousCoordinates: boolean;
  77668. /**
  77669. * The coordinate system mode. Defaults to AUTO.
  77670. */
  77671. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  77672. /**
  77673. * The animation start mode. Defaults to FIRST.
  77674. */
  77675. animationStartMode: GLTFLoaderAnimationStartMode;
  77676. /**
  77677. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  77678. */
  77679. compileMaterials: boolean;
  77680. /**
  77681. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  77682. */
  77683. useClipPlane: boolean;
  77684. /**
  77685. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  77686. */
  77687. compileShadowGenerators: boolean;
  77688. /**
  77689. * Defines if the Alpha blended materials are only applied as coverage.
  77690. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  77691. * If true, no extra effects are applied to transparent pixels.
  77692. */
  77693. transparencyAsCoverage: boolean;
  77694. /**
  77695. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  77696. * Enabling will disable offline support and glTF validator.
  77697. * Defaults to false.
  77698. */
  77699. useRangeRequests: boolean;
  77700. /**
  77701. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  77702. */
  77703. createInstances: boolean;
  77704. /**
  77705. * Function called before loading a url referenced by the asset.
  77706. */
  77707. preprocessUrlAsync: (url: string) => Promise<string>;
  77708. /**
  77709. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  77710. */
  77711. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  77712. private _onMeshLoadedObserver;
  77713. /**
  77714. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  77715. */
  77716. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  77717. /**
  77718. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  77719. */
  77720. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  77721. private _onTextureLoadedObserver;
  77722. /**
  77723. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  77724. */
  77725. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  77726. /**
  77727. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  77728. */
  77729. readonly onMaterialLoadedObservable: Observable<Material>;
  77730. private _onMaterialLoadedObserver;
  77731. /**
  77732. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  77733. */
  77734. set onMaterialLoaded(callback: (material: Material) => void);
  77735. /**
  77736. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  77737. */
  77738. readonly onCameraLoadedObservable: Observable<Camera>;
  77739. private _onCameraLoadedObserver;
  77740. /**
  77741. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  77742. */
  77743. set onCameraLoaded(callback: (camera: Camera) => void);
  77744. /**
  77745. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  77746. * For assets with LODs, raised when all of the LODs are complete.
  77747. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  77748. */
  77749. readonly onCompleteObservable: Observable<void>;
  77750. private _onCompleteObserver;
  77751. /**
  77752. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  77753. * For assets with LODs, raised when all of the LODs are complete.
  77754. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  77755. */
  77756. set onComplete(callback: () => void);
  77757. /**
  77758. * Observable raised when an error occurs.
  77759. */
  77760. readonly onErrorObservable: Observable<any>;
  77761. private _onErrorObserver;
  77762. /**
  77763. * Callback raised when an error occurs.
  77764. */
  77765. set onError(callback: (reason: any) => void);
  77766. /**
  77767. * Observable raised after the loader is disposed.
  77768. */
  77769. readonly onDisposeObservable: Observable<void>;
  77770. private _onDisposeObserver;
  77771. /**
  77772. * Callback raised after the loader is disposed.
  77773. */
  77774. set onDispose(callback: () => void);
  77775. /**
  77776. * Observable raised after a loader extension is created.
  77777. * Set additional options for a loader extension in this event.
  77778. */
  77779. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  77780. private _onExtensionLoadedObserver;
  77781. /**
  77782. * Callback raised after a loader extension is created.
  77783. */
  77784. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  77785. /**
  77786. * Defines if the loader logging is enabled.
  77787. */
  77788. get loggingEnabled(): boolean;
  77789. set loggingEnabled(value: boolean);
  77790. /**
  77791. * Defines if the loader should capture performance counters.
  77792. */
  77793. get capturePerformanceCounters(): boolean;
  77794. set capturePerformanceCounters(value: boolean);
  77795. /**
  77796. * Defines if the loader should validate the asset.
  77797. */
  77798. validate: boolean;
  77799. /**
  77800. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  77801. */
  77802. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  77803. private _onValidatedObserver;
  77804. /**
  77805. * Callback raised after a loader extension is created.
  77806. */
  77807. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  77808. private _loader;
  77809. /**
  77810. * Name of the loader ("gltf")
  77811. */
  77812. name: string;
  77813. /** @hidden */
  77814. extensions: ISceneLoaderPluginExtensions;
  77815. /**
  77816. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  77817. */
  77818. dispose(): void;
  77819. /** @hidden */
  77820. _clear(): void;
  77821. /** @hidden */
  77822. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  77823. /** @hidden */
  77824. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  77825. /** @hidden */
  77826. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  77827. meshes: AbstractMesh[];
  77828. particleSystems: IParticleSystem[];
  77829. skeletons: Skeleton[];
  77830. animationGroups: AnimationGroup[];
  77831. }>;
  77832. /** @hidden */
  77833. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  77834. /** @hidden */
  77835. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  77836. /** @hidden */
  77837. canDirectLoad(data: string): boolean;
  77838. /** @hidden */
  77839. directLoad(scene: Scene, data: string): any;
  77840. /**
  77841. * The callback that allows custom handling of the root url based on the response url.
  77842. * @param rootUrl the original root url
  77843. * @param responseURL the response url if available
  77844. * @returns the new root url
  77845. */
  77846. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  77847. /** @hidden */
  77848. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  77849. /**
  77850. * The loader state or null if the loader is not active.
  77851. */
  77852. get loaderState(): Nullable<GLTFLoaderState>;
  77853. /**
  77854. * Returns a promise that resolves when the asset is completely loaded.
  77855. * @returns a promise that resolves when the asset is completely loaded.
  77856. */
  77857. whenCompleteAsync(): Promise<void>;
  77858. private _validate;
  77859. private _getLoader;
  77860. private _parseJson;
  77861. private _unpackBinaryAsync;
  77862. private _unpackBinaryV1Async;
  77863. private _unpackBinaryV2Async;
  77864. private static _parseVersion;
  77865. private static _compareVersion;
  77866. private static readonly _logSpaces;
  77867. private _logIndentLevel;
  77868. private _loggingEnabled;
  77869. /** @hidden */
  77870. _log: (message: string) => void;
  77871. /** @hidden */
  77872. _logOpen(message: string): void;
  77873. /** @hidden */
  77874. _logClose(): void;
  77875. private _logEnabled;
  77876. private _logDisabled;
  77877. private _capturePerformanceCounters;
  77878. /** @hidden */
  77879. _startPerformanceCounter: (counterName: string) => void;
  77880. /** @hidden */
  77881. _endPerformanceCounter: (counterName: string) => void;
  77882. private _startPerformanceCounterEnabled;
  77883. private _startPerformanceCounterDisabled;
  77884. private _endPerformanceCounterEnabled;
  77885. private _endPerformanceCounterDisabled;
  77886. }
  77887. }
  77888. declare module BABYLON.GLTF1 {
  77889. /**
  77890. * Enums
  77891. * @hidden
  77892. */
  77893. export enum EComponentType {
  77894. BYTE = 5120,
  77895. UNSIGNED_BYTE = 5121,
  77896. SHORT = 5122,
  77897. UNSIGNED_SHORT = 5123,
  77898. FLOAT = 5126
  77899. }
  77900. /** @hidden */
  77901. export enum EShaderType {
  77902. FRAGMENT = 35632,
  77903. VERTEX = 35633
  77904. }
  77905. /** @hidden */
  77906. export enum EParameterType {
  77907. BYTE = 5120,
  77908. UNSIGNED_BYTE = 5121,
  77909. SHORT = 5122,
  77910. UNSIGNED_SHORT = 5123,
  77911. INT = 5124,
  77912. UNSIGNED_INT = 5125,
  77913. FLOAT = 5126,
  77914. FLOAT_VEC2 = 35664,
  77915. FLOAT_VEC3 = 35665,
  77916. FLOAT_VEC4 = 35666,
  77917. INT_VEC2 = 35667,
  77918. INT_VEC3 = 35668,
  77919. INT_VEC4 = 35669,
  77920. BOOL = 35670,
  77921. BOOL_VEC2 = 35671,
  77922. BOOL_VEC3 = 35672,
  77923. BOOL_VEC4 = 35673,
  77924. FLOAT_MAT2 = 35674,
  77925. FLOAT_MAT3 = 35675,
  77926. FLOAT_MAT4 = 35676,
  77927. SAMPLER_2D = 35678
  77928. }
  77929. /** @hidden */
  77930. export enum ETextureWrapMode {
  77931. CLAMP_TO_EDGE = 33071,
  77932. MIRRORED_REPEAT = 33648,
  77933. REPEAT = 10497
  77934. }
  77935. /** @hidden */
  77936. export enum ETextureFilterType {
  77937. NEAREST = 9728,
  77938. LINEAR = 9728,
  77939. NEAREST_MIPMAP_NEAREST = 9984,
  77940. LINEAR_MIPMAP_NEAREST = 9985,
  77941. NEAREST_MIPMAP_LINEAR = 9986,
  77942. LINEAR_MIPMAP_LINEAR = 9987
  77943. }
  77944. /** @hidden */
  77945. export enum ETextureFormat {
  77946. ALPHA = 6406,
  77947. RGB = 6407,
  77948. RGBA = 6408,
  77949. LUMINANCE = 6409,
  77950. LUMINANCE_ALPHA = 6410
  77951. }
  77952. /** @hidden */
  77953. export enum ECullingType {
  77954. FRONT = 1028,
  77955. BACK = 1029,
  77956. FRONT_AND_BACK = 1032
  77957. }
  77958. /** @hidden */
  77959. export enum EBlendingFunction {
  77960. ZERO = 0,
  77961. ONE = 1,
  77962. SRC_COLOR = 768,
  77963. ONE_MINUS_SRC_COLOR = 769,
  77964. DST_COLOR = 774,
  77965. ONE_MINUS_DST_COLOR = 775,
  77966. SRC_ALPHA = 770,
  77967. ONE_MINUS_SRC_ALPHA = 771,
  77968. DST_ALPHA = 772,
  77969. ONE_MINUS_DST_ALPHA = 773,
  77970. CONSTANT_COLOR = 32769,
  77971. ONE_MINUS_CONSTANT_COLOR = 32770,
  77972. CONSTANT_ALPHA = 32771,
  77973. ONE_MINUS_CONSTANT_ALPHA = 32772,
  77974. SRC_ALPHA_SATURATE = 776
  77975. }
  77976. /** @hidden */
  77977. export interface IGLTFProperty {
  77978. extensions?: {
  77979. [key: string]: any;
  77980. };
  77981. extras?: Object;
  77982. }
  77983. /** @hidden */
  77984. export interface IGLTFChildRootProperty extends IGLTFProperty {
  77985. name?: string;
  77986. }
  77987. /** @hidden */
  77988. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  77989. bufferView: string;
  77990. byteOffset: number;
  77991. byteStride: number;
  77992. count: number;
  77993. type: string;
  77994. componentType: EComponentType;
  77995. max?: number[];
  77996. min?: number[];
  77997. name?: string;
  77998. }
  77999. /** @hidden */
  78000. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  78001. buffer: string;
  78002. byteOffset: number;
  78003. byteLength: number;
  78004. byteStride: number;
  78005. target?: number;
  78006. }
  78007. /** @hidden */
  78008. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  78009. uri: string;
  78010. byteLength?: number;
  78011. type?: string;
  78012. }
  78013. /** @hidden */
  78014. export interface IGLTFShader extends IGLTFChildRootProperty {
  78015. uri: string;
  78016. type: EShaderType;
  78017. }
  78018. /** @hidden */
  78019. export interface IGLTFProgram extends IGLTFChildRootProperty {
  78020. attributes: string[];
  78021. fragmentShader: string;
  78022. vertexShader: string;
  78023. }
  78024. /** @hidden */
  78025. export interface IGLTFTechniqueParameter {
  78026. type: number;
  78027. count?: number;
  78028. semantic?: string;
  78029. node?: string;
  78030. value?: number | boolean | string | Array<any>;
  78031. source?: string;
  78032. babylonValue?: any;
  78033. }
  78034. /** @hidden */
  78035. export interface IGLTFTechniqueCommonProfile {
  78036. lightingModel: string;
  78037. texcoordBindings: Object;
  78038. parameters?: Array<any>;
  78039. }
  78040. /** @hidden */
  78041. export interface IGLTFTechniqueStatesFunctions {
  78042. blendColor?: number[];
  78043. blendEquationSeparate?: number[];
  78044. blendFuncSeparate?: number[];
  78045. colorMask: boolean[];
  78046. cullFace: number[];
  78047. }
  78048. /** @hidden */
  78049. export interface IGLTFTechniqueStates {
  78050. enable: number[];
  78051. functions: IGLTFTechniqueStatesFunctions;
  78052. }
  78053. /** @hidden */
  78054. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  78055. parameters: {
  78056. [key: string]: IGLTFTechniqueParameter;
  78057. };
  78058. program: string;
  78059. attributes: {
  78060. [key: string]: string;
  78061. };
  78062. uniforms: {
  78063. [key: string]: string;
  78064. };
  78065. states: IGLTFTechniqueStates;
  78066. }
  78067. /** @hidden */
  78068. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  78069. technique?: string;
  78070. values: string[];
  78071. }
  78072. /** @hidden */
  78073. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  78074. attributes: {
  78075. [key: string]: string;
  78076. };
  78077. indices: string;
  78078. material: string;
  78079. mode?: number;
  78080. }
  78081. /** @hidden */
  78082. export interface IGLTFMesh extends IGLTFChildRootProperty {
  78083. primitives: IGLTFMeshPrimitive[];
  78084. }
  78085. /** @hidden */
  78086. export interface IGLTFImage extends IGLTFChildRootProperty {
  78087. uri: string;
  78088. }
  78089. /** @hidden */
  78090. export interface IGLTFSampler extends IGLTFChildRootProperty {
  78091. magFilter?: number;
  78092. minFilter?: number;
  78093. wrapS?: number;
  78094. wrapT?: number;
  78095. }
  78096. /** @hidden */
  78097. export interface IGLTFTexture extends IGLTFChildRootProperty {
  78098. sampler: string;
  78099. source: string;
  78100. format?: ETextureFormat;
  78101. internalFormat?: ETextureFormat;
  78102. target?: number;
  78103. type?: number;
  78104. babylonTexture?: Texture;
  78105. }
  78106. /** @hidden */
  78107. export interface IGLTFAmbienLight {
  78108. color?: number[];
  78109. }
  78110. /** @hidden */
  78111. export interface IGLTFDirectionalLight {
  78112. color?: number[];
  78113. }
  78114. /** @hidden */
  78115. export interface IGLTFPointLight {
  78116. color?: number[];
  78117. constantAttenuation?: number;
  78118. linearAttenuation?: number;
  78119. quadraticAttenuation?: number;
  78120. }
  78121. /** @hidden */
  78122. export interface IGLTFSpotLight {
  78123. color?: number[];
  78124. constantAttenuation?: number;
  78125. fallOfAngle?: number;
  78126. fallOffExponent?: number;
  78127. linearAttenuation?: number;
  78128. quadraticAttenuation?: number;
  78129. }
  78130. /** @hidden */
  78131. export interface IGLTFLight extends IGLTFChildRootProperty {
  78132. type: string;
  78133. }
  78134. /** @hidden */
  78135. export interface IGLTFCameraOrthographic {
  78136. xmag: number;
  78137. ymag: number;
  78138. zfar: number;
  78139. znear: number;
  78140. }
  78141. /** @hidden */
  78142. export interface IGLTFCameraPerspective {
  78143. aspectRatio: number;
  78144. yfov: number;
  78145. zfar: number;
  78146. znear: number;
  78147. }
  78148. /** @hidden */
  78149. export interface IGLTFCamera extends IGLTFChildRootProperty {
  78150. type: string;
  78151. }
  78152. /** @hidden */
  78153. export interface IGLTFAnimationChannelTarget {
  78154. id: string;
  78155. path: string;
  78156. }
  78157. /** @hidden */
  78158. export interface IGLTFAnimationChannel {
  78159. sampler: string;
  78160. target: IGLTFAnimationChannelTarget;
  78161. }
  78162. /** @hidden */
  78163. export interface IGLTFAnimationSampler {
  78164. input: string;
  78165. output: string;
  78166. interpolation?: string;
  78167. }
  78168. /** @hidden */
  78169. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  78170. channels?: IGLTFAnimationChannel[];
  78171. parameters?: {
  78172. [key: string]: string;
  78173. };
  78174. samplers?: {
  78175. [key: string]: IGLTFAnimationSampler;
  78176. };
  78177. }
  78178. /** @hidden */
  78179. export interface IGLTFNodeInstanceSkin {
  78180. skeletons: string[];
  78181. skin: string;
  78182. meshes: string[];
  78183. }
  78184. /** @hidden */
  78185. export interface IGLTFSkins extends IGLTFChildRootProperty {
  78186. bindShapeMatrix: number[];
  78187. inverseBindMatrices: string;
  78188. jointNames: string[];
  78189. babylonSkeleton?: Skeleton;
  78190. }
  78191. /** @hidden */
  78192. export interface IGLTFNode extends IGLTFChildRootProperty {
  78193. camera?: string;
  78194. children: string[];
  78195. skin?: string;
  78196. jointName?: string;
  78197. light?: string;
  78198. matrix: number[];
  78199. mesh?: string;
  78200. meshes?: string[];
  78201. rotation?: number[];
  78202. scale?: number[];
  78203. translation?: number[];
  78204. babylonNode?: Node;
  78205. }
  78206. /** @hidden */
  78207. export interface IGLTFScene extends IGLTFChildRootProperty {
  78208. nodes: string[];
  78209. }
  78210. /** @hidden */
  78211. export interface IGLTFRuntime {
  78212. extensions: {
  78213. [key: string]: any;
  78214. };
  78215. accessors: {
  78216. [key: string]: IGLTFAccessor;
  78217. };
  78218. buffers: {
  78219. [key: string]: IGLTFBuffer;
  78220. };
  78221. bufferViews: {
  78222. [key: string]: IGLTFBufferView;
  78223. };
  78224. meshes: {
  78225. [key: string]: IGLTFMesh;
  78226. };
  78227. lights: {
  78228. [key: string]: IGLTFLight;
  78229. };
  78230. cameras: {
  78231. [key: string]: IGLTFCamera;
  78232. };
  78233. nodes: {
  78234. [key: string]: IGLTFNode;
  78235. };
  78236. images: {
  78237. [key: string]: IGLTFImage;
  78238. };
  78239. textures: {
  78240. [key: string]: IGLTFTexture;
  78241. };
  78242. shaders: {
  78243. [key: string]: IGLTFShader;
  78244. };
  78245. programs: {
  78246. [key: string]: IGLTFProgram;
  78247. };
  78248. samplers: {
  78249. [key: string]: IGLTFSampler;
  78250. };
  78251. techniques: {
  78252. [key: string]: IGLTFTechnique;
  78253. };
  78254. materials: {
  78255. [key: string]: IGLTFMaterial;
  78256. };
  78257. animations: {
  78258. [key: string]: IGLTFAnimation;
  78259. };
  78260. skins: {
  78261. [key: string]: IGLTFSkins;
  78262. };
  78263. currentScene?: Object;
  78264. scenes: {
  78265. [key: string]: IGLTFScene;
  78266. };
  78267. extensionsUsed: string[];
  78268. extensionsRequired?: string[];
  78269. buffersCount: number;
  78270. shaderscount: number;
  78271. scene: Scene;
  78272. rootUrl: string;
  78273. loadedBufferCount: number;
  78274. loadedBufferViews: {
  78275. [name: string]: ArrayBufferView;
  78276. };
  78277. loadedShaderCount: number;
  78278. importOnlyMeshes: boolean;
  78279. importMeshesNames?: string[];
  78280. dummyNodes: Node[];
  78281. forAssetContainer: boolean;
  78282. }
  78283. /** @hidden */
  78284. export interface INodeToRoot {
  78285. bone: Bone;
  78286. node: IGLTFNode;
  78287. id: string;
  78288. }
  78289. /** @hidden */
  78290. export interface IJointNode {
  78291. node: IGLTFNode;
  78292. id: string;
  78293. }
  78294. }
  78295. declare module BABYLON.GLTF1 {
  78296. /**
  78297. * Utils functions for GLTF
  78298. * @hidden
  78299. */
  78300. export class GLTFUtils {
  78301. /**
  78302. * Sets the given "parameter" matrix
  78303. * @param scene: the Scene object
  78304. * @param source: the source node where to pick the matrix
  78305. * @param parameter: the GLTF technique parameter
  78306. * @param uniformName: the name of the shader's uniform
  78307. * @param shaderMaterial: the shader material
  78308. */
  78309. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  78310. /**
  78311. * Sets the given "parameter" matrix
  78312. * @param shaderMaterial: the shader material
  78313. * @param uniform: the name of the shader's uniform
  78314. * @param value: the value of the uniform
  78315. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  78316. */
  78317. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  78318. /**
  78319. * Returns the wrap mode of the texture
  78320. * @param mode: the mode value
  78321. */
  78322. static GetWrapMode(mode: number): number;
  78323. /**
  78324. * Returns the byte stride giving an accessor
  78325. * @param accessor: the GLTF accessor objet
  78326. */
  78327. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  78328. /**
  78329. * Returns the texture filter mode giving a mode value
  78330. * @param mode: the filter mode value
  78331. */
  78332. static GetTextureFilterMode(mode: number): ETextureFilterType;
  78333. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  78334. /**
  78335. * Returns a buffer from its accessor
  78336. * @param gltfRuntime: the GLTF runtime
  78337. * @param accessor: the GLTF accessor
  78338. */
  78339. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  78340. /**
  78341. * Decodes a buffer view into a string
  78342. * @param view: the buffer view
  78343. */
  78344. static DecodeBufferToText(view: ArrayBufferView): string;
  78345. /**
  78346. * Returns the default material of gltf. Related to
  78347. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  78348. * @param scene: the Babylon.js scene
  78349. */
  78350. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  78351. private static _DefaultMaterial;
  78352. }
  78353. }
  78354. declare module BABYLON.GLTF1 {
  78355. /**
  78356. * Implementation of the base glTF spec
  78357. * @hidden
  78358. */
  78359. export class GLTFLoaderBase {
  78360. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  78361. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  78362. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  78363. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  78364. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  78365. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  78366. }
  78367. /**
  78368. * glTF V1 Loader
  78369. * @hidden
  78370. */
  78371. export class GLTFLoader implements IGLTFLoader {
  78372. static Extensions: {
  78373. [name: string]: GLTFLoaderExtension;
  78374. };
  78375. static RegisterExtension(extension: GLTFLoaderExtension): void;
  78376. state: Nullable<GLTFLoaderState>;
  78377. dispose(): void;
  78378. private _importMeshAsync;
  78379. /**
  78380. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  78381. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  78382. * @param scene the scene the meshes should be added to
  78383. * @param forAssetContainer defines if the entities must be stored in the scene
  78384. * @param data gltf data containing information of the meshes in a loaded file
  78385. * @param rootUrl root url to load from
  78386. * @param onProgress event that fires when loading progress has occured
  78387. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  78388. */
  78389. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  78390. private _loadAsync;
  78391. /**
  78392. * Imports all objects from a loaded gltf file and adds them to the scene
  78393. * @param scene the scene the objects should be added to
  78394. * @param data gltf data containing information of the meshes in a loaded file
  78395. * @param rootUrl root url to load from
  78396. * @param onProgress event that fires when loading progress has occured
  78397. * @returns a promise which completes when objects have been loaded to the scene
  78398. */
  78399. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  78400. private _loadShadersAsync;
  78401. private _loadBuffersAsync;
  78402. private _createNodes;
  78403. }
  78404. /** @hidden */
  78405. export abstract class GLTFLoaderExtension {
  78406. private _name;
  78407. constructor(name: string);
  78408. get name(): string;
  78409. /**
  78410. * Defines an override for loading the runtime
  78411. * Return true to stop further extensions from loading the runtime
  78412. */
  78413. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  78414. /**
  78415. * Defines an onverride for creating gltf runtime
  78416. * Return true to stop further extensions from creating the runtime
  78417. */
  78418. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  78419. /**
  78420. * Defines an override for loading buffers
  78421. * Return true to stop further extensions from loading this buffer
  78422. */
  78423. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  78424. /**
  78425. * Defines an override for loading texture buffers
  78426. * Return true to stop further extensions from loading this texture data
  78427. */
  78428. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  78429. /**
  78430. * Defines an override for creating textures
  78431. * Return true to stop further extensions from loading this texture
  78432. */
  78433. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  78434. /**
  78435. * Defines an override for loading shader strings
  78436. * Return true to stop further extensions from loading this shader data
  78437. */
  78438. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  78439. /**
  78440. * Defines an override for loading materials
  78441. * Return true to stop further extensions from loading this material
  78442. */
  78443. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  78444. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  78445. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  78446. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  78447. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  78448. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  78449. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  78450. private static LoadTextureBufferAsync;
  78451. private static CreateTextureAsync;
  78452. private static ApplyExtensions;
  78453. }
  78454. }
  78455. declare module BABYLON.GLTF1 {
  78456. /** @hidden */
  78457. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  78458. private _bin;
  78459. constructor();
  78460. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  78461. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  78462. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  78463. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  78464. }
  78465. }
  78466. declare module BABYLON.GLTF1 {
  78467. /** @hidden */
  78468. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  78469. constructor();
  78470. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  78471. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  78472. private _loadTexture;
  78473. }
  78474. }
  78475. declare module BABYLON.GLTF2.Loader {
  78476. /**
  78477. * Loader interface with an index field.
  78478. */
  78479. export interface IArrayItem {
  78480. /**
  78481. * The index of this item in the array.
  78482. */
  78483. index: number;
  78484. }
  78485. /**
  78486. * Loader interface with additional members.
  78487. */
  78488. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  78489. /** @hidden */
  78490. _data?: Promise<ArrayBufferView>;
  78491. /** @hidden */
  78492. _babylonVertexBuffer?: Promise<VertexBuffer>;
  78493. }
  78494. /**
  78495. * Loader interface with additional members.
  78496. */
  78497. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  78498. }
  78499. /** @hidden */
  78500. export interface _IAnimationSamplerData {
  78501. input: Float32Array;
  78502. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  78503. output: Float32Array;
  78504. }
  78505. /**
  78506. * Loader interface with additional members.
  78507. */
  78508. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  78509. /** @hidden */
  78510. _data?: Promise<_IAnimationSamplerData>;
  78511. }
  78512. /**
  78513. * Loader interface with additional members.
  78514. */
  78515. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  78516. channels: IAnimationChannel[];
  78517. samplers: IAnimationSampler[];
  78518. /** @hidden */
  78519. _babylonAnimationGroup?: AnimationGroup;
  78520. }
  78521. /**
  78522. * Loader interface with additional members.
  78523. */
  78524. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  78525. /** @hidden */
  78526. _data?: Promise<ArrayBufferView>;
  78527. }
  78528. /**
  78529. * Loader interface with additional members.
  78530. */
  78531. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  78532. /** @hidden */
  78533. _data?: Promise<ArrayBufferView>;
  78534. /** @hidden */
  78535. _babylonBuffer?: Promise<Buffer>;
  78536. }
  78537. /**
  78538. * Loader interface with additional members.
  78539. */
  78540. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  78541. }
  78542. /**
  78543. * Loader interface with additional members.
  78544. */
  78545. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  78546. /** @hidden */
  78547. _data?: Promise<ArrayBufferView>;
  78548. }
  78549. /**
  78550. * Loader interface with additional members.
  78551. */
  78552. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  78553. }
  78554. /**
  78555. * Loader interface with additional members.
  78556. */
  78557. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  78558. }
  78559. /**
  78560. * Loader interface with additional members.
  78561. */
  78562. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  78563. baseColorTexture?: ITextureInfo;
  78564. metallicRoughnessTexture?: ITextureInfo;
  78565. }
  78566. /**
  78567. * Loader interface with additional members.
  78568. */
  78569. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  78570. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  78571. normalTexture?: IMaterialNormalTextureInfo;
  78572. occlusionTexture?: IMaterialOcclusionTextureInfo;
  78573. emissiveTexture?: ITextureInfo;
  78574. /** @hidden */
  78575. _data?: {
  78576. [babylonDrawMode: number]: {
  78577. babylonMaterial: Material;
  78578. babylonMeshes: AbstractMesh[];
  78579. promise: Promise<void>;
  78580. };
  78581. };
  78582. }
  78583. /**
  78584. * Loader interface with additional members.
  78585. */
  78586. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  78587. primitives: IMeshPrimitive[];
  78588. }
  78589. /**
  78590. * Loader interface with additional members.
  78591. */
  78592. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  78593. /** @hidden */
  78594. _instanceData?: {
  78595. babylonSourceMesh: Mesh;
  78596. promise: Promise<any>;
  78597. };
  78598. }
  78599. /**
  78600. * Loader interface with additional members.
  78601. */
  78602. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  78603. /**
  78604. * The parent glTF node.
  78605. */
  78606. parent?: INode;
  78607. /** @hidden */
  78608. _babylonTransformNode?: TransformNode;
  78609. /** @hidden */
  78610. _primitiveBabylonMeshes?: AbstractMesh[];
  78611. /** @hidden */
  78612. _babylonBones?: Bone[];
  78613. /** @hidden */
  78614. _numMorphTargets?: number;
  78615. }
  78616. /** @hidden */
  78617. export interface _ISamplerData {
  78618. noMipMaps: boolean;
  78619. samplingMode: number;
  78620. wrapU: number;
  78621. wrapV: number;
  78622. }
  78623. /**
  78624. * Loader interface with additional members.
  78625. */
  78626. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  78627. /** @hidden */
  78628. _data?: _ISamplerData;
  78629. }
  78630. /**
  78631. * Loader interface with additional members.
  78632. */
  78633. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  78634. }
  78635. /**
  78636. * Loader interface with additional members.
  78637. */
  78638. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  78639. /** @hidden */
  78640. _data?: {
  78641. babylonSkeleton: Skeleton;
  78642. promise: Promise<void>;
  78643. };
  78644. }
  78645. /**
  78646. * Loader interface with additional members.
  78647. */
  78648. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  78649. }
  78650. /**
  78651. * Loader interface with additional members.
  78652. */
  78653. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  78654. }
  78655. /**
  78656. * Loader interface with additional members.
  78657. */
  78658. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  78659. accessors?: IAccessor[];
  78660. animations?: IAnimation[];
  78661. buffers?: IBuffer[];
  78662. bufferViews?: IBufferView[];
  78663. cameras?: ICamera[];
  78664. images?: IImage[];
  78665. materials?: IMaterial[];
  78666. meshes?: IMesh[];
  78667. nodes?: INode[];
  78668. samplers?: ISampler[];
  78669. scenes?: IScene[];
  78670. skins?: ISkin[];
  78671. textures?: ITexture[];
  78672. }
  78673. }
  78674. declare module BABYLON.GLTF2 {
  78675. /**
  78676. * Interface for a glTF loader extension.
  78677. */
  78678. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  78679. /**
  78680. * Called after the loader state changes to LOADING.
  78681. */
  78682. onLoading?(): void;
  78683. /**
  78684. * Called after the loader state changes to READY.
  78685. */
  78686. onReady?(): void;
  78687. /**
  78688. * Define this method to modify the default behavior when loading scenes.
  78689. * @param context The context when loading the asset
  78690. * @param scene The glTF scene property
  78691. * @returns A promise that resolves when the load is complete or null if not handled
  78692. */
  78693. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  78694. /**
  78695. * Define this method to modify the default behavior when loading nodes.
  78696. * @param context The context when loading the asset
  78697. * @param node The glTF node property
  78698. * @param assign A function called synchronously after parsing the glTF properties
  78699. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  78700. */
  78701. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  78702. /**
  78703. * Define this method to modify the default behavior when loading cameras.
  78704. * @param context The context when loading the asset
  78705. * @param camera The glTF camera property
  78706. * @param assign A function called synchronously after parsing the glTF properties
  78707. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  78708. */
  78709. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  78710. /**
  78711. * @hidden
  78712. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  78713. * @param context The context when loading the asset
  78714. * @param primitive The glTF mesh primitive property
  78715. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  78716. */
  78717. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  78718. /**
  78719. * @hidden
  78720. * Define this method to modify the default behavior when loading data for mesh primitives.
  78721. * @param context The context when loading the asset
  78722. * @param name The mesh name when loading the asset
  78723. * @param node The glTF node when loading the asset
  78724. * @param mesh The glTF mesh when loading the asset
  78725. * @param primitive The glTF mesh primitive property
  78726. * @param assign A function called synchronously after parsing the glTF properties
  78727. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  78728. */
  78729. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  78730. /**
  78731. * @hidden
  78732. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  78733. * @param context The context when loading the asset
  78734. * @param material The glTF material property
  78735. * @param assign A function called synchronously after parsing the glTF properties
  78736. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  78737. */
  78738. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  78739. /**
  78740. * Define this method to modify the default behavior when creating materials.
  78741. * @param context The context when loading the asset
  78742. * @param material The glTF material property
  78743. * @param babylonDrawMode The draw mode for the Babylon material
  78744. * @returns The Babylon material or null if not handled
  78745. */
  78746. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  78747. /**
  78748. * Define this method to modify the default behavior when loading material properties.
  78749. * @param context The context when loading the asset
  78750. * @param material The glTF material property
  78751. * @param babylonMaterial The Babylon material
  78752. * @returns A promise that resolves when the load is complete or null if not handled
  78753. */
  78754. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  78755. /**
  78756. * Define this method to modify the default behavior when loading texture infos.
  78757. * @param context The context when loading the asset
  78758. * @param textureInfo The glTF texture info property
  78759. * @param assign A function called synchronously after parsing the glTF properties
  78760. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  78761. */
  78762. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  78763. /**
  78764. * @hidden
  78765. * Define this method to modify the default behavior when loading textures.
  78766. * @param context The context when loading the asset
  78767. * @param texture The glTF texture property
  78768. * @param assign A function called synchronously after parsing the glTF properties
  78769. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  78770. */
  78771. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  78772. /**
  78773. * Define this method to modify the default behavior when loading animations.
  78774. * @param context The context when loading the asset
  78775. * @param animation The glTF animation property
  78776. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  78777. */
  78778. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  78779. /**
  78780. * @hidden
  78781. * Define this method to modify the default behavior when loading skins.
  78782. * @param context The context when loading the asset
  78783. * @param node The glTF node property
  78784. * @param skin The glTF skin property
  78785. * @returns A promise that resolves when the load is complete or null if not handled
  78786. */
  78787. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  78788. /**
  78789. * @hidden
  78790. * Define this method to modify the default behavior when loading uris.
  78791. * @param context The context when loading the asset
  78792. * @param property The glTF property associated with the uri
  78793. * @param uri The uri to load
  78794. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  78795. */
  78796. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  78797. /**
  78798. * Define this method to modify the default behavior when loading buffer views.
  78799. * @param context The context when loading the asset
  78800. * @param bufferView The glTF buffer view property
  78801. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  78802. */
  78803. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  78804. /**
  78805. * Define this method to modify the default behavior when loading buffers.
  78806. * @param context The context when loading the asset
  78807. * @param buffer The glTF buffer property
  78808. * @param byteOffset The byte offset to load
  78809. * @param byteLength The byte length to load
  78810. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  78811. */
  78812. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  78813. }
  78814. }
  78815. declare module BABYLON.GLTF2 {
  78816. /**
  78817. * Helper class for working with arrays when loading the glTF asset
  78818. */
  78819. export class ArrayItem {
  78820. /**
  78821. * Gets an item from the given array.
  78822. * @param context The context when loading the asset
  78823. * @param array The array to get the item from
  78824. * @param index The index to the array
  78825. * @returns The array item
  78826. */
  78827. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  78828. /**
  78829. * Assign an `index` field to each item of the given array.
  78830. * @param array The array of items
  78831. */
  78832. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  78833. }
  78834. /**
  78835. * The glTF 2.0 loader
  78836. */
  78837. export class GLTFLoader implements IGLTFLoader {
  78838. /** @hidden */
  78839. _completePromises: Promise<any>[];
  78840. /** @hidden */
  78841. _forAssetContainer: boolean;
  78842. /** Storage */
  78843. _babylonLights: Light[];
  78844. private _disposed;
  78845. private _parent;
  78846. private _state;
  78847. private _extensions;
  78848. private _rootUrl;
  78849. private _fileName;
  78850. private _uniqueRootUrl;
  78851. private _gltf;
  78852. private _bin;
  78853. private _babylonScene;
  78854. private _rootBabylonMesh;
  78855. private _defaultBabylonMaterialData;
  78856. private _progressCallback?;
  78857. private _requests;
  78858. private static _RegisteredExtensions;
  78859. /**
  78860. * The default glTF sampler.
  78861. */
  78862. static readonly DefaultSampler: ISampler;
  78863. /**
  78864. * Registers a loader extension.
  78865. * @param name The name of the loader extension.
  78866. * @param factory The factory function that creates the loader extension.
  78867. */
  78868. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  78869. /**
  78870. * Unregisters a loader extension.
  78871. * @param name The name of the loader extension.
  78872. * @returns A boolean indicating whether the extension has been unregistered
  78873. */
  78874. static UnregisterExtension(name: string): boolean;
  78875. /**
  78876. * The loader state.
  78877. */
  78878. get state(): Nullable<GLTFLoaderState>;
  78879. /**
  78880. * The object that represents the glTF JSON.
  78881. */
  78882. get gltf(): IGLTF;
  78883. /**
  78884. * The BIN chunk of a binary glTF.
  78885. */
  78886. get bin(): Nullable<IDataBuffer>;
  78887. /**
  78888. * The parent file loader.
  78889. */
  78890. get parent(): GLTFFileLoader;
  78891. /**
  78892. * The Babylon scene when loading the asset.
  78893. */
  78894. get babylonScene(): Scene;
  78895. /**
  78896. * The root Babylon mesh when loading the asset.
  78897. */
  78898. get rootBabylonMesh(): Mesh;
  78899. /** @hidden */
  78900. constructor(parent: GLTFFileLoader);
  78901. /** @hidden */
  78902. dispose(): void;
  78903. /** @hidden */
  78904. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  78905. /** @hidden */
  78906. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  78907. private _loadAsync;
  78908. private _loadData;
  78909. private _setupData;
  78910. private _loadExtensions;
  78911. private _checkExtensions;
  78912. private _setState;
  78913. private _createRootNode;
  78914. /**
  78915. * Loads a glTF scene.
  78916. * @param context The context when loading the asset
  78917. * @param scene The glTF scene property
  78918. * @returns A promise that resolves when the load is complete
  78919. */
  78920. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  78921. private _forEachPrimitive;
  78922. private _getMeshes;
  78923. private _getTransformNodes;
  78924. private _getSkeletons;
  78925. private _getAnimationGroups;
  78926. private _startAnimations;
  78927. /**
  78928. * Loads a glTF node.
  78929. * @param context The context when loading the asset
  78930. * @param node The glTF node property
  78931. * @param assign A function called synchronously after parsing the glTF properties
  78932. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  78933. */
  78934. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  78935. private _loadMeshAsync;
  78936. /**
  78937. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  78938. * @param context The context when loading the asset
  78939. * @param name The mesh name when loading the asset
  78940. * @param node The glTF node when loading the asset
  78941. * @param mesh The glTF mesh when loading the asset
  78942. * @param primitive The glTF mesh primitive property
  78943. * @param assign A function called synchronously after parsing the glTF properties
  78944. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  78945. */
  78946. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  78947. private _loadVertexDataAsync;
  78948. private _createMorphTargets;
  78949. private _loadMorphTargetsAsync;
  78950. private _loadMorphTargetVertexDataAsync;
  78951. private static _LoadTransform;
  78952. private _loadSkinAsync;
  78953. private _loadBones;
  78954. private _loadBone;
  78955. private _loadSkinInverseBindMatricesDataAsync;
  78956. private _updateBoneMatrices;
  78957. private _getNodeMatrix;
  78958. /**
  78959. * Loads a glTF camera.
  78960. * @param context The context when loading the asset
  78961. * @param camera The glTF camera property
  78962. * @param assign A function called synchronously after parsing the glTF properties
  78963. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  78964. */
  78965. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  78966. private _loadAnimationsAsync;
  78967. /**
  78968. * Loads a glTF animation.
  78969. * @param context The context when loading the asset
  78970. * @param animation The glTF animation property
  78971. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  78972. */
  78973. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  78974. /**
  78975. * @hidden Loads a glTF animation channel.
  78976. * @param context The context when loading the asset
  78977. * @param animationContext The context of the animation when loading the asset
  78978. * @param animation The glTF animation property
  78979. * @param channel The glTF animation channel property
  78980. * @param babylonAnimationGroup The babylon animation group property
  78981. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  78982. * @returns A void promise when the channel load is complete
  78983. */
  78984. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  78985. private _loadAnimationSamplerAsync;
  78986. private _loadBufferAsync;
  78987. /**
  78988. * Loads a glTF buffer view.
  78989. * @param context The context when loading the asset
  78990. * @param bufferView The glTF buffer view property
  78991. * @returns A promise that resolves with the loaded data when the load is complete
  78992. */
  78993. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  78994. private _loadAccessorAsync;
  78995. /** @hidden */
  78996. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  78997. private _loadIndicesAccessorAsync;
  78998. private _loadVertexBufferViewAsync;
  78999. private _loadVertexAccessorAsync;
  79000. private _loadMaterialMetallicRoughnessPropertiesAsync;
  79001. /** @hidden */
  79002. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  79003. private _createDefaultMaterial;
  79004. /**
  79005. * Creates a Babylon material from a glTF material.
  79006. * @param context The context when loading the asset
  79007. * @param material The glTF material property
  79008. * @param babylonDrawMode The draw mode for the Babylon material
  79009. * @returns The Babylon material
  79010. */
  79011. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  79012. /**
  79013. * Loads properties from a glTF material into a Babylon material.
  79014. * @param context The context when loading the asset
  79015. * @param material The glTF material property
  79016. * @param babylonMaterial The Babylon material
  79017. * @returns A promise that resolves when the load is complete
  79018. */
  79019. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  79020. /**
  79021. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  79022. * @param context The context when loading the asset
  79023. * @param material The glTF material property
  79024. * @param babylonMaterial The Babylon material
  79025. * @returns A promise that resolves when the load is complete
  79026. */
  79027. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  79028. /**
  79029. * Loads the alpha properties from a glTF material into a Babylon material.
  79030. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  79031. * @param context The context when loading the asset
  79032. * @param material The glTF material property
  79033. * @param babylonMaterial The Babylon material
  79034. */
  79035. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  79036. /**
  79037. * Loads a glTF texture info.
  79038. * @param context The context when loading the asset
  79039. * @param textureInfo The glTF texture info property
  79040. * @param assign A function called synchronously after parsing the glTF properties
  79041. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  79042. */
  79043. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79044. /** @hidden */
  79045. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79046. /** @hidden */
  79047. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79048. private _loadSampler;
  79049. /**
  79050. * Loads a glTF image.
  79051. * @param context The context when loading the asset
  79052. * @param image The glTF image property
  79053. * @returns A promise that resolves with the loaded data when the load is complete
  79054. */
  79055. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  79056. /**
  79057. * Loads a glTF uri.
  79058. * @param context The context when loading the asset
  79059. * @param property The glTF property associated with the uri
  79060. * @param uri The base64 or relative uri
  79061. * @returns A promise that resolves with the loaded data when the load is complete
  79062. */
  79063. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  79064. private _onProgress;
  79065. /**
  79066. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  79067. * @param babylonObject the Babylon object with metadata
  79068. * @param pointer the JSON pointer
  79069. */
  79070. static AddPointerMetadata(babylonObject: {
  79071. metadata: any;
  79072. }, pointer: string): void;
  79073. private static _GetTextureWrapMode;
  79074. private static _GetTextureSamplingMode;
  79075. private static _GetTypedArrayConstructor;
  79076. private static _GetTypedArray;
  79077. private static _GetNumComponents;
  79078. private static _ValidateUri;
  79079. private static _GetDrawMode;
  79080. private _compileMaterialsAsync;
  79081. private _compileShadowGeneratorsAsync;
  79082. private _forEachExtensions;
  79083. private _applyExtensions;
  79084. private _extensionsOnLoading;
  79085. private _extensionsOnReady;
  79086. private _extensionsLoadSceneAsync;
  79087. private _extensionsLoadNodeAsync;
  79088. private _extensionsLoadCameraAsync;
  79089. private _extensionsLoadVertexDataAsync;
  79090. private _extensionsLoadMeshPrimitiveAsync;
  79091. private _extensionsLoadMaterialAsync;
  79092. private _extensionsCreateMaterial;
  79093. private _extensionsLoadMaterialPropertiesAsync;
  79094. private _extensionsLoadTextureInfoAsync;
  79095. private _extensionsLoadTextureAsync;
  79096. private _extensionsLoadAnimationAsync;
  79097. private _extensionsLoadSkinAsync;
  79098. private _extensionsLoadUriAsync;
  79099. private _extensionsLoadBufferViewAsync;
  79100. private _extensionsLoadBufferAsync;
  79101. /**
  79102. * Helper method called by a loader extension to load an glTF extension.
  79103. * @param context The context when loading the asset
  79104. * @param property The glTF property to load the extension from
  79105. * @param extensionName The name of the extension to load
  79106. * @param actionAsync The action to run
  79107. * @returns The promise returned by actionAsync or null if the extension does not exist
  79108. */
  79109. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  79110. /**
  79111. * Helper method called by a loader extension to load a glTF extra.
  79112. * @param context The context when loading the asset
  79113. * @param property The glTF property to load the extra from
  79114. * @param extensionName The name of the extension to load
  79115. * @param actionAsync The action to run
  79116. * @returns The promise returned by actionAsync or null if the extra does not exist
  79117. */
  79118. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  79119. /**
  79120. * Checks for presence of an extension.
  79121. * @param name The name of the extension to check
  79122. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  79123. */
  79124. isExtensionUsed(name: string): boolean;
  79125. /**
  79126. * Increments the indentation level and logs a message.
  79127. * @param message The message to log
  79128. */
  79129. logOpen(message: string): void;
  79130. /**
  79131. * Decrements the indentation level.
  79132. */
  79133. logClose(): void;
  79134. /**
  79135. * Logs a message
  79136. * @param message The message to log
  79137. */
  79138. log(message: string): void;
  79139. /**
  79140. * Starts a performance counter.
  79141. * @param counterName The name of the performance counter
  79142. */
  79143. startPerformanceCounter(counterName: string): void;
  79144. /**
  79145. * Ends a performance counter.
  79146. * @param counterName The name of the performance counter
  79147. */
  79148. endPerformanceCounter(counterName: string): void;
  79149. }
  79150. }
  79151. declare module BABYLON.GLTF2.Loader.Extensions {
  79152. /**
  79153. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  79154. */
  79155. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  79156. /**
  79157. * The name of this extension.
  79158. */
  79159. readonly name: string;
  79160. /**
  79161. * Defines whether this extension is enabled.
  79162. */
  79163. enabled: boolean;
  79164. private _loader;
  79165. private _lights?;
  79166. /** @hidden */
  79167. constructor(loader: GLTFLoader);
  79168. /** @hidden */
  79169. dispose(): void;
  79170. /** @hidden */
  79171. onLoading(): void;
  79172. /** @hidden */
  79173. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  79174. private _loadLightAsync;
  79175. }
  79176. }
  79177. declare module BABYLON.GLTF2.Loader.Extensions {
  79178. /**
  79179. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  79180. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  79181. * !!! Experimental Extension Subject to Changes !!!
  79182. */
  79183. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  79184. /**
  79185. * The name of this extension.
  79186. */
  79187. readonly name: string;
  79188. /**
  79189. * Defines whether this extension is enabled.
  79190. */
  79191. enabled: boolean;
  79192. private _loader;
  79193. /** @hidden */
  79194. constructor(loader: GLTFLoader);
  79195. /** @hidden */
  79196. dispose(): void;
  79197. /** @hidden */
  79198. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79199. }
  79200. }
  79201. declare module BABYLON.GLTF2.Loader.Extensions {
  79202. /**
  79203. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  79204. */
  79205. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  79206. /**
  79207. * The name of this extension.
  79208. */
  79209. readonly name: string;
  79210. /**
  79211. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  79212. */
  79213. dracoCompression?: DracoCompression;
  79214. /**
  79215. * Defines whether this extension is enabled.
  79216. */
  79217. enabled: boolean;
  79218. private _loader;
  79219. /** @hidden */
  79220. constructor(loader: GLTFLoader);
  79221. /** @hidden */
  79222. dispose(): void;
  79223. /** @hidden */
  79224. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  79225. }
  79226. }
  79227. declare module BABYLON.GLTF2.Loader.Extensions {
  79228. /**
  79229. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  79230. */
  79231. export class KHR_lights implements IGLTFLoaderExtension {
  79232. /**
  79233. * The name of this extension.
  79234. */
  79235. readonly name: string;
  79236. /**
  79237. * Defines whether this extension is enabled.
  79238. */
  79239. enabled: boolean;
  79240. private _loader;
  79241. private _lights?;
  79242. /** @hidden */
  79243. constructor(loader: GLTFLoader);
  79244. /** @hidden */
  79245. dispose(): void;
  79246. /** @hidden */
  79247. onLoading(): void;
  79248. /** @hidden */
  79249. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79250. }
  79251. }
  79252. declare module BABYLON.GLTF2.Loader.Extensions {
  79253. /**
  79254. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  79255. */
  79256. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  79257. /**
  79258. * The name of this extension.
  79259. */
  79260. readonly name: string;
  79261. /**
  79262. * Defines whether this extension is enabled.
  79263. */
  79264. enabled: boolean;
  79265. /**
  79266. * Defines a number that determines the order the extensions are applied.
  79267. */
  79268. order: number;
  79269. private _loader;
  79270. /** @hidden */
  79271. constructor(loader: GLTFLoader);
  79272. /** @hidden */
  79273. dispose(): void;
  79274. /** @hidden */
  79275. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79276. private _loadSpecularGlossinessPropertiesAsync;
  79277. }
  79278. }
  79279. declare module BABYLON.GLTF2.Loader.Extensions {
  79280. /**
  79281. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  79282. */
  79283. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  79284. /**
  79285. * The name of this extension.
  79286. */
  79287. readonly name: string;
  79288. /**
  79289. * Defines whether this extension is enabled.
  79290. */
  79291. enabled: boolean;
  79292. /**
  79293. * Defines a number that determines the order the extensions are applied.
  79294. */
  79295. order: number;
  79296. private _loader;
  79297. /** @hidden */
  79298. constructor(loader: GLTFLoader);
  79299. /** @hidden */
  79300. dispose(): void;
  79301. /** @hidden */
  79302. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79303. private _loadUnlitPropertiesAsync;
  79304. }
  79305. }
  79306. declare module BABYLON.GLTF2.Loader.Extensions {
  79307. /**
  79308. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  79309. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  79310. * !!! Experimental Extension Subject to Changes !!!
  79311. */
  79312. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  79313. /**
  79314. * The name of this extension.
  79315. */
  79316. readonly name: string;
  79317. /**
  79318. * Defines whether this extension is enabled.
  79319. */
  79320. enabled: boolean;
  79321. /**
  79322. * Defines a number that determines the order the extensions are applied.
  79323. */
  79324. order: number;
  79325. private _loader;
  79326. /** @hidden */
  79327. constructor(loader: GLTFLoader);
  79328. /** @hidden */
  79329. dispose(): void;
  79330. /** @hidden */
  79331. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79332. private _loadClearCoatPropertiesAsync;
  79333. }
  79334. }
  79335. declare module BABYLON.GLTF2.Loader.Extensions {
  79336. /**
  79337. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  79338. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  79339. * !!! Experimental Extension Subject to Changes !!!
  79340. */
  79341. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  79342. /**
  79343. * The name of this extension.
  79344. */
  79345. readonly name: string;
  79346. /**
  79347. * Defines whether this extension is enabled.
  79348. */
  79349. enabled: boolean;
  79350. /**
  79351. * Defines a number that determines the order the extensions are applied.
  79352. */
  79353. order: number;
  79354. private _loader;
  79355. /** @hidden */
  79356. constructor(loader: GLTFLoader);
  79357. /** @hidden */
  79358. dispose(): void;
  79359. /** @hidden */
  79360. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79361. private _loadSheenPropertiesAsync;
  79362. }
  79363. }
  79364. declare module BABYLON.GLTF2.Loader.Extensions {
  79365. /**
  79366. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  79367. * !!! Experimental Extension Subject to Changes !!!
  79368. */
  79369. export class KHR_materials_specular implements IGLTFLoaderExtension {
  79370. /**
  79371. * The name of this extension.
  79372. */
  79373. readonly name: string;
  79374. /**
  79375. * Defines whether this extension is enabled.
  79376. */
  79377. enabled: boolean;
  79378. /**
  79379. * Defines a number that determines the order the extensions are applied.
  79380. */
  79381. order: number;
  79382. private _loader;
  79383. /** @hidden */
  79384. constructor(loader: GLTFLoader);
  79385. /** @hidden */
  79386. dispose(): void;
  79387. /** @hidden */
  79388. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79389. private _loadSpecularPropertiesAsync;
  79390. }
  79391. }
  79392. declare module BABYLON.GLTF2.Loader.Extensions {
  79393. /**
  79394. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  79395. * !!! Experimental Extension Subject to Changes !!!
  79396. */
  79397. export class KHR_materials_ior implements IGLTFLoaderExtension {
  79398. /**
  79399. * Default ior Value from the spec.
  79400. */
  79401. private static readonly _DEFAULT_IOR;
  79402. /**
  79403. * The name of this extension.
  79404. */
  79405. readonly name: string;
  79406. /**
  79407. * Defines whether this extension is enabled.
  79408. */
  79409. enabled: boolean;
  79410. /**
  79411. * Defines a number that determines the order the extensions are applied.
  79412. */
  79413. order: number;
  79414. private _loader;
  79415. /** @hidden */
  79416. constructor(loader: GLTFLoader);
  79417. /** @hidden */
  79418. dispose(): void;
  79419. /** @hidden */
  79420. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79421. private _loadIorPropertiesAsync;
  79422. }
  79423. }
  79424. declare module BABYLON.GLTF2.Loader.Extensions {
  79425. /**
  79426. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  79427. */
  79428. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  79429. /**
  79430. * The name of this extension.
  79431. */
  79432. readonly name: string;
  79433. /**
  79434. * Defines whether this extension is enabled.
  79435. */
  79436. enabled: boolean;
  79437. /** @hidden */
  79438. constructor(loader: GLTFLoader);
  79439. /** @hidden */
  79440. dispose(): void;
  79441. }
  79442. }
  79443. declare module BABYLON.GLTF2.Loader.Extensions {
  79444. /**
  79445. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  79446. * !!! Experimental Extension Subject to Changes !!!
  79447. */
  79448. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  79449. /** The name of this extension. */
  79450. readonly name: string;
  79451. /** Defines whether this extension is enabled. */
  79452. enabled: boolean;
  79453. private _loader;
  79454. /** @hidden */
  79455. constructor(loader: GLTFLoader);
  79456. /** @hidden */
  79457. dispose(): void;
  79458. /** @hidden */
  79459. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  79460. }
  79461. }
  79462. declare module BABYLON.GLTF2.Loader.Extensions {
  79463. /**
  79464. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  79465. */
  79466. export class KHR_texture_transform implements IGLTFLoaderExtension {
  79467. /**
  79468. * The name of this extension.
  79469. */
  79470. readonly name: string;
  79471. /**
  79472. * Defines whether this extension is enabled.
  79473. */
  79474. enabled: boolean;
  79475. private _loader;
  79476. /** @hidden */
  79477. constructor(loader: GLTFLoader);
  79478. /** @hidden */
  79479. dispose(): void;
  79480. /** @hidden */
  79481. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  79482. }
  79483. }
  79484. declare module BABYLON.GLTF2.Loader.Extensions {
  79485. /**
  79486. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  79487. */
  79488. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  79489. /**
  79490. * The name of this extension.
  79491. */
  79492. readonly name: string;
  79493. /**
  79494. * Defines whether this extension is enabled.
  79495. */
  79496. enabled: boolean;
  79497. private _loader;
  79498. private _clips;
  79499. private _emitters;
  79500. /** @hidden */
  79501. constructor(loader: GLTFLoader);
  79502. /** @hidden */
  79503. dispose(): void;
  79504. /** @hidden */
  79505. onLoading(): void;
  79506. /** @hidden */
  79507. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  79508. /** @hidden */
  79509. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79510. /** @hidden */
  79511. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  79512. private _loadClipAsync;
  79513. private _loadEmitterAsync;
  79514. private _getEventAction;
  79515. private _loadAnimationEventAsync;
  79516. }
  79517. }
  79518. declare module BABYLON.GLTF2.Loader.Extensions {
  79519. /**
  79520. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  79521. */
  79522. export class MSFT_lod implements IGLTFLoaderExtension {
  79523. /**
  79524. * The name of this extension.
  79525. */
  79526. readonly name: string;
  79527. /**
  79528. * Defines whether this extension is enabled.
  79529. */
  79530. enabled: boolean;
  79531. /**
  79532. * Defines a number that determines the order the extensions are applied.
  79533. */
  79534. order: number;
  79535. /**
  79536. * Maximum number of LODs to load, starting from the lowest LOD.
  79537. */
  79538. maxLODsToLoad: number;
  79539. /**
  79540. * Observable raised when all node LODs of one level are loaded.
  79541. * The event data is the index of the loaded LOD starting from zero.
  79542. * Dispose the loader to cancel the loading of the next level of LODs.
  79543. */
  79544. onNodeLODsLoadedObservable: Observable<number>;
  79545. /**
  79546. * Observable raised when all material LODs of one level are loaded.
  79547. * The event data is the index of the loaded LOD starting from zero.
  79548. * Dispose the loader to cancel the loading of the next level of LODs.
  79549. */
  79550. onMaterialLODsLoadedObservable: Observable<number>;
  79551. private _loader;
  79552. private _nodeIndexLOD;
  79553. private _nodeSignalLODs;
  79554. private _nodePromiseLODs;
  79555. private _materialIndexLOD;
  79556. private _materialSignalLODs;
  79557. private _materialPromiseLODs;
  79558. private _indexLOD;
  79559. private _bufferLODs;
  79560. /** @hidden */
  79561. constructor(loader: GLTFLoader);
  79562. /** @hidden */
  79563. dispose(): void;
  79564. /** @hidden */
  79565. onReady(): void;
  79566. /** @hidden */
  79567. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  79568. /** @hidden */
  79569. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79570. /** @hidden */
  79571. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  79572. /** @hidden */
  79573. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  79574. /** @hidden */
  79575. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  79576. private _loadBufferLOD;
  79577. /**
  79578. * Gets an array of LOD properties from lowest to highest.
  79579. */
  79580. private _getLODs;
  79581. private _disposeTransformNode;
  79582. private _disposeMaterials;
  79583. }
  79584. }
  79585. declare module BABYLON.GLTF2.Loader.Extensions {
  79586. /** @hidden */
  79587. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  79588. readonly name: string;
  79589. enabled: boolean;
  79590. private _loader;
  79591. constructor(loader: GLTFLoader);
  79592. dispose(): void;
  79593. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79594. }
  79595. }
  79596. declare module BABYLON.GLTF2.Loader.Extensions {
  79597. /** @hidden */
  79598. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  79599. readonly name: string;
  79600. enabled: boolean;
  79601. private _loader;
  79602. constructor(loader: GLTFLoader);
  79603. dispose(): void;
  79604. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79605. }
  79606. }
  79607. declare module BABYLON.GLTF2.Loader.Extensions {
  79608. /**
  79609. * Store glTF extras (if present) in BJS objects' metadata
  79610. */
  79611. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  79612. /**
  79613. * The name of this extension.
  79614. */
  79615. readonly name: string;
  79616. /**
  79617. * Defines whether this extension is enabled.
  79618. */
  79619. enabled: boolean;
  79620. private _loader;
  79621. private _assignExtras;
  79622. /** @hidden */
  79623. constructor(loader: GLTFLoader);
  79624. /** @hidden */
  79625. dispose(): void;
  79626. /** @hidden */
  79627. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79628. /** @hidden */
  79629. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  79630. /** @hidden */
  79631. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  79632. }
  79633. }
  79634. declare module BABYLON {
  79635. /**
  79636. * Class reading and parsing the MTL file bundled with the obj file.
  79637. */
  79638. export class MTLFileLoader {
  79639. /**
  79640. * Invert Y-Axis of referenced textures on load
  79641. */
  79642. static INVERT_TEXTURE_Y: boolean;
  79643. /**
  79644. * All material loaded from the mtl will be set here
  79645. */
  79646. materials: StandardMaterial[];
  79647. /**
  79648. * This function will read the mtl file and create each material described inside
  79649. * This function could be improve by adding :
  79650. * -some component missing (Ni, Tf...)
  79651. * -including the specific options available
  79652. *
  79653. * @param scene defines the scene the material will be created in
  79654. * @param data defines the mtl data to parse
  79655. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  79656. * @param forAssetContainer defines if the material should be registered in the scene
  79657. */
  79658. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  79659. /**
  79660. * Gets the texture for the material.
  79661. *
  79662. * If the material is imported from input file,
  79663. * We sanitize the url to ensure it takes the textre from aside the material.
  79664. *
  79665. * @param rootUrl The root url to load from
  79666. * @param value The value stored in the mtl
  79667. * @return The Texture
  79668. */
  79669. private static _getTexture;
  79670. }
  79671. }
  79672. declare module BABYLON {
  79673. /**
  79674. * Options for loading OBJ/MTL files
  79675. */
  79676. type MeshLoadOptions = {
  79677. /**
  79678. * Defines if UVs are optimized by default during load.
  79679. */
  79680. OptimizeWithUV: boolean;
  79681. /**
  79682. * Defines custom scaling of UV coordinates of loaded meshes.
  79683. */
  79684. UVScaling: Vector2;
  79685. /**
  79686. * Invert model on y-axis (does a model scaling inversion)
  79687. */
  79688. InvertY: boolean;
  79689. /**
  79690. * Invert Y-Axis of referenced textures on load
  79691. */
  79692. InvertTextureY: boolean;
  79693. /**
  79694. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  79695. */
  79696. ImportVertexColors: boolean;
  79697. /**
  79698. * Compute the normals for the model, even if normals are present in the file.
  79699. */
  79700. ComputeNormals: boolean;
  79701. /**
  79702. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  79703. */
  79704. SkipMaterials: boolean;
  79705. /**
  79706. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  79707. */
  79708. MaterialLoadingFailsSilently: boolean;
  79709. };
  79710. /**
  79711. * OBJ file type loader.
  79712. * This is a babylon scene loader plugin.
  79713. */
  79714. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  79715. /**
  79716. * Defines if UVs are optimized by default during load.
  79717. */
  79718. static OPTIMIZE_WITH_UV: boolean;
  79719. /**
  79720. * Invert model on y-axis (does a model scaling inversion)
  79721. */
  79722. static INVERT_Y: boolean;
  79723. /**
  79724. * Invert Y-Axis of referenced textures on load
  79725. */
  79726. static get INVERT_TEXTURE_Y(): boolean;
  79727. static set INVERT_TEXTURE_Y(value: boolean);
  79728. /**
  79729. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  79730. */
  79731. static IMPORT_VERTEX_COLORS: boolean;
  79732. /**
  79733. * Compute the normals for the model, even if normals are present in the file.
  79734. */
  79735. static COMPUTE_NORMALS: boolean;
  79736. /**
  79737. * Defines custom scaling of UV coordinates of loaded meshes.
  79738. */
  79739. static UV_SCALING: Vector2;
  79740. /**
  79741. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  79742. */
  79743. static SKIP_MATERIALS: boolean;
  79744. /**
  79745. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  79746. *
  79747. * Defaults to true for backwards compatibility.
  79748. */
  79749. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  79750. /**
  79751. * Defines the name of the plugin.
  79752. */
  79753. name: string;
  79754. /**
  79755. * Defines the extension the plugin is able to load.
  79756. */
  79757. extensions: string;
  79758. /** @hidden */
  79759. obj: RegExp;
  79760. /** @hidden */
  79761. group: RegExp;
  79762. /** @hidden */
  79763. mtllib: RegExp;
  79764. /** @hidden */
  79765. usemtl: RegExp;
  79766. /** @hidden */
  79767. smooth: RegExp;
  79768. /** @hidden */
  79769. vertexPattern: RegExp;
  79770. /** @hidden */
  79771. normalPattern: RegExp;
  79772. /** @hidden */
  79773. uvPattern: RegExp;
  79774. /** @hidden */
  79775. facePattern1: RegExp;
  79776. /** @hidden */
  79777. facePattern2: RegExp;
  79778. /** @hidden */
  79779. facePattern3: RegExp;
  79780. /** @hidden */
  79781. facePattern4: RegExp;
  79782. /** @hidden */
  79783. facePattern5: RegExp;
  79784. private _forAssetContainer;
  79785. private _meshLoadOptions;
  79786. /**
  79787. * Creates loader for .OBJ files
  79788. *
  79789. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  79790. */
  79791. constructor(meshLoadOptions?: MeshLoadOptions);
  79792. private static get currentMeshLoadOptions();
  79793. /**
  79794. * Calls synchronously the MTL file attached to this obj.
  79795. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  79796. * Without this function materials are not displayed in the first frame (but displayed after).
  79797. * In consequence it is impossible to get material information in your HTML file
  79798. *
  79799. * @param url The URL of the MTL file
  79800. * @param rootUrl
  79801. * @param onSuccess Callback function to be called when the MTL file is loaded
  79802. * @private
  79803. */
  79804. private _loadMTL;
  79805. /**
  79806. * Instantiates a OBJ file loader plugin.
  79807. * @returns the created plugin
  79808. */
  79809. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  79810. /**
  79811. * If the data string can be loaded directly.
  79812. *
  79813. * @param data string containing the file data
  79814. * @returns if the data can be loaded directly
  79815. */
  79816. canDirectLoad(data: string): boolean;
  79817. /**
  79818. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  79819. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  79820. * @param scene the scene the meshes should be added to
  79821. * @param data the OBJ data to load
  79822. * @param rootUrl root url to load from
  79823. * @param onProgress event that fires when loading progress has occured
  79824. * @param fileName Defines the name of the file to load
  79825. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  79826. */
  79827. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  79828. meshes: AbstractMesh[];
  79829. particleSystems: IParticleSystem[];
  79830. skeletons: Skeleton[];
  79831. animationGroups: AnimationGroup[];
  79832. }>;
  79833. /**
  79834. * Imports all objects from the loaded OBJ data and adds them to the scene
  79835. * @param scene the scene the objects should be added to
  79836. * @param data the OBJ data to load
  79837. * @param rootUrl root url to load from
  79838. * @param onProgress event that fires when loading progress has occured
  79839. * @param fileName Defines the name of the file to load
  79840. * @returns a promise which completes when objects have been loaded to the scene
  79841. */
  79842. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  79843. /**
  79844. * Load into an asset container.
  79845. * @param scene The scene to load into
  79846. * @param data The data to import
  79847. * @param rootUrl The root url for scene and resources
  79848. * @param onProgress The callback when the load progresses
  79849. * @param fileName Defines the name of the file to load
  79850. * @returns The loaded asset container
  79851. */
  79852. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  79853. /**
  79854. * Read the OBJ file and create an Array of meshes.
  79855. * Each mesh contains all information given by the OBJ and the MTL file.
  79856. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  79857. *
  79858. * @param meshesNames
  79859. * @param scene Scene The scene where are displayed the data
  79860. * @param data String The content of the obj file
  79861. * @param rootUrl String The path to the folder
  79862. * @returns Array<AbstractMesh>
  79863. * @private
  79864. */
  79865. private _parseSolid;
  79866. }
  79867. }
  79868. declare module BABYLON {
  79869. /**
  79870. * STL file type loader.
  79871. * This is a babylon scene loader plugin.
  79872. */
  79873. export class STLFileLoader implements ISceneLoaderPlugin {
  79874. /** @hidden */
  79875. solidPattern: RegExp;
  79876. /** @hidden */
  79877. facetsPattern: RegExp;
  79878. /** @hidden */
  79879. normalPattern: RegExp;
  79880. /** @hidden */
  79881. vertexPattern: RegExp;
  79882. /**
  79883. * Defines the name of the plugin.
  79884. */
  79885. name: string;
  79886. /**
  79887. * Defines the extensions the stl loader is able to load.
  79888. * force data to come in as an ArrayBuffer
  79889. * we'll convert to string if it looks like it's an ASCII .stl
  79890. */
  79891. extensions: ISceneLoaderPluginExtensions;
  79892. /**
  79893. * Import meshes into a scene.
  79894. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  79895. * @param scene The scene to import into
  79896. * @param data The data to import
  79897. * @param rootUrl The root url for scene and resources
  79898. * @param meshes The meshes array to import into
  79899. * @param particleSystems The particle systems array to import into
  79900. * @param skeletons The skeletons array to import into
  79901. * @param onError The callback when import fails
  79902. * @returns True if successful or false otherwise
  79903. */
  79904. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  79905. /**
  79906. * Load into a scene.
  79907. * @param scene The scene to load into
  79908. * @param data The data to import
  79909. * @param rootUrl The root url for scene and resources
  79910. * @param onError The callback when import fails
  79911. * @returns true if successful or false otherwise
  79912. */
  79913. load(scene: Scene, data: any, rootUrl: string): boolean;
  79914. /**
  79915. * Load into an asset container.
  79916. * @param scene The scene to load into
  79917. * @param data The data to import
  79918. * @param rootUrl The root url for scene and resources
  79919. * @param onError The callback when import fails
  79920. * @returns The loaded asset container
  79921. */
  79922. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  79923. private _isBinary;
  79924. private _parseBinary;
  79925. private _parseASCII;
  79926. }
  79927. }
  79928. declare module BABYLON {
  79929. /**
  79930. * Class for generating OBJ data from a Babylon scene.
  79931. */
  79932. export class OBJExport {
  79933. /**
  79934. * Exports the geometry of a Mesh array in .OBJ file format (text)
  79935. * @param mesh defines the list of meshes to serialize
  79936. * @param materials defines if materials should be exported
  79937. * @param matlibname defines the name of the associated mtl file
  79938. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  79939. * @returns the OBJ content
  79940. */
  79941. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  79942. /**
  79943. * Exports the material(s) of a mesh in .MTL file format (text)
  79944. * @param mesh defines the mesh to extract the material from
  79945. * @returns the mtl content
  79946. */
  79947. static MTL(mesh: Mesh): string;
  79948. }
  79949. }
  79950. declare module BABYLON {
  79951. /** @hidden */
  79952. export var __IGLTFExporterExtension: number;
  79953. /**
  79954. * Interface for extending the exporter
  79955. * @hidden
  79956. */
  79957. export interface IGLTFExporterExtension {
  79958. /**
  79959. * The name of this extension
  79960. */
  79961. readonly name: string;
  79962. /**
  79963. * Defines whether this extension is enabled
  79964. */
  79965. enabled: boolean;
  79966. /**
  79967. * Defines whether this extension is required
  79968. */
  79969. required: boolean;
  79970. }
  79971. }
  79972. declare module BABYLON.GLTF2.Exporter {
  79973. /** @hidden */
  79974. export var __IGLTFExporterExtensionV2: number;
  79975. /**
  79976. * Interface for a glTF exporter extension
  79977. * @hidden
  79978. */
  79979. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  79980. /**
  79981. * Define this method to modify the default behavior before exporting a texture
  79982. * @param context The context when loading the asset
  79983. * @param babylonTexture The Babylon.js texture
  79984. * @param mimeType The mime-type of the generated image
  79985. * @returns A promise that resolves with the exported texture
  79986. */
  79987. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  79988. /**
  79989. * Define this method to get notified when a texture info is created
  79990. * @param context The context when loading the asset
  79991. * @param textureInfo The glTF texture info
  79992. * @param babylonTexture The Babylon.js texture
  79993. */
  79994. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  79995. /**
  79996. * Define this method to modify the default behavior when exporting texture info
  79997. * @param context The context when loading the asset
  79998. * @param meshPrimitive glTF mesh primitive
  79999. * @param babylonSubMesh Babylon submesh
  80000. * @param binaryWriter glTF serializer binary writer instance
  80001. * @returns nullable IMeshPrimitive promise
  80002. */
  80003. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  80004. /**
  80005. * Define this method to modify the default behavior when exporting a node
  80006. * @param context The context when exporting the node
  80007. * @param node glTF node
  80008. * @param babylonNode BabylonJS node
  80009. * @returns nullable INode promise
  80010. */
  80011. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  80012. [key: number]: number;
  80013. }): Promise<Nullable<INode>>;
  80014. /**
  80015. * Define this method to modify the default behavior when exporting a material
  80016. * @param material glTF material
  80017. * @param babylonMaterial BabylonJS material
  80018. * @returns nullable IMaterial promise
  80019. */
  80020. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  80021. /**
  80022. * Define this method to return additional textures to export from a material
  80023. * @param material glTF material
  80024. * @param babylonMaterial BabylonJS material
  80025. * @returns List of textures
  80026. */
  80027. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  80028. /** Gets a boolean indicating that this extension was used */
  80029. wasUsed: boolean;
  80030. /** Gets a boolean indicating that this extension is required for the file to work */
  80031. required: boolean;
  80032. /**
  80033. * Called after the exporter state changes to EXPORTING
  80034. */
  80035. onExporting?(): void;
  80036. }
  80037. }
  80038. declare module BABYLON.GLTF2.Exporter {
  80039. /**
  80040. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  80041. * @hidden
  80042. */
  80043. export class _GLTFMaterialExporter {
  80044. /**
  80045. * Represents the dielectric specular values for R, G and B
  80046. */
  80047. private static readonly _DielectricSpecular;
  80048. /**
  80049. * Allows the maximum specular power to be defined for material calculations
  80050. */
  80051. private static readonly _MaxSpecularPower;
  80052. /**
  80053. * Mapping to store textures
  80054. */
  80055. private _textureMap;
  80056. /**
  80057. * Numeric tolerance value
  80058. */
  80059. private static readonly _Epsilon;
  80060. /**
  80061. * Reference to the glTF Exporter
  80062. */
  80063. private _exporter;
  80064. constructor(exporter: _Exporter);
  80065. /**
  80066. * Specifies if two colors are approximately equal in value
  80067. * @param color1 first color to compare to
  80068. * @param color2 second color to compare to
  80069. * @param epsilon threshold value
  80070. */
  80071. private static FuzzyEquals;
  80072. /**
  80073. * Gets the materials from a Babylon scene and converts them to glTF materials
  80074. * @param scene babylonjs scene
  80075. * @param mimeType texture mime type
  80076. * @param images array of images
  80077. * @param textures array of textures
  80078. * @param materials array of materials
  80079. * @param imageData mapping of texture names to base64 textures
  80080. * @param hasTextureCoords specifies if texture coordinates are present on the material
  80081. */
  80082. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  80083. /**
  80084. * Makes a copy of the glTF material without the texture parameters
  80085. * @param originalMaterial original glTF material
  80086. * @returns glTF material without texture parameters
  80087. */
  80088. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  80089. /**
  80090. * Specifies if the material has any texture parameters present
  80091. * @param material glTF Material
  80092. * @returns boolean specifying if texture parameters are present
  80093. */
  80094. _hasTexturesPresent(material: IMaterial): boolean;
  80095. /**
  80096. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  80097. * @param babylonStandardMaterial
  80098. * @returns glTF Metallic Roughness Material representation
  80099. */
  80100. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  80101. /**
  80102. * Computes the metallic factor
  80103. * @param diffuse diffused value
  80104. * @param specular specular value
  80105. * @param oneMinusSpecularStrength one minus the specular strength
  80106. * @returns metallic value
  80107. */
  80108. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  80109. /**
  80110. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  80111. * @param glTFMaterial glTF material
  80112. * @param babylonMaterial Babylon material
  80113. */
  80114. private static _SetAlphaMode;
  80115. /**
  80116. * Converts a Babylon Standard Material to a glTF Material
  80117. * @param babylonStandardMaterial BJS Standard Material
  80118. * @param mimeType mime type to use for the textures
  80119. * @param images array of glTF image interfaces
  80120. * @param textures array of glTF texture interfaces
  80121. * @param materials array of glTF material interfaces
  80122. * @param imageData map of image file name to data
  80123. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80124. */
  80125. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  80126. private _finishMaterial;
  80127. /**
  80128. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  80129. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  80130. * @param mimeType mime type to use for the textures
  80131. * @param images array of glTF image interfaces
  80132. * @param textures array of glTF texture interfaces
  80133. * @param materials array of glTF material interfaces
  80134. * @param imageData map of image file name to data
  80135. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80136. */
  80137. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  80138. /**
  80139. * Converts an image typed array buffer to a base64 image
  80140. * @param buffer typed array buffer
  80141. * @param width width of the image
  80142. * @param height height of the image
  80143. * @param mimeType mimetype of the image
  80144. * @returns base64 image string
  80145. */
  80146. private _createBase64FromCanvasAsync;
  80147. /**
  80148. * Generates a white texture based on the specified width and height
  80149. * @param width width of the texture in pixels
  80150. * @param height height of the texture in pixels
  80151. * @param scene babylonjs scene
  80152. * @returns white texture
  80153. */
  80154. private _createWhiteTexture;
  80155. /**
  80156. * 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
  80157. * @param texture1 first texture to resize
  80158. * @param texture2 second texture to resize
  80159. * @param scene babylonjs scene
  80160. * @returns resized textures or null
  80161. */
  80162. private _resizeTexturesToSameDimensions;
  80163. /**
  80164. * Converts an array of pixels to a Float32Array
  80165. * Throws an error if the pixel format is not supported
  80166. * @param pixels - array buffer containing pixel values
  80167. * @returns Float32 of pixels
  80168. */
  80169. private _convertPixelArrayToFloat32;
  80170. /**
  80171. * Convert Specular Glossiness Textures to Metallic Roughness
  80172. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  80173. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  80174. * @param diffuseTexture texture used to store diffuse information
  80175. * @param specularGlossinessTexture texture used to store specular and glossiness information
  80176. * @param factors specular glossiness material factors
  80177. * @param mimeType the mime type to use for the texture
  80178. * @returns pbr metallic roughness interface or null
  80179. */
  80180. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  80181. /**
  80182. * Converts specular glossiness material properties to metallic roughness
  80183. * @param specularGlossiness interface with specular glossiness material properties
  80184. * @returns interface with metallic roughness material properties
  80185. */
  80186. private _convertSpecularGlossinessToMetallicRoughness;
  80187. /**
  80188. * Calculates the surface reflectance, independent of lighting conditions
  80189. * @param color Color source to calculate brightness from
  80190. * @returns number representing the perceived brightness, or zero if color is undefined
  80191. */
  80192. private _getPerceivedBrightness;
  80193. /**
  80194. * Returns the maximum color component value
  80195. * @param color
  80196. * @returns maximum color component value, or zero if color is null or undefined
  80197. */
  80198. private _getMaxComponent;
  80199. /**
  80200. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  80201. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  80202. * @param mimeType mime type to use for the textures
  80203. * @param images array of glTF image interfaces
  80204. * @param textures array of glTF texture interfaces
  80205. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  80206. * @param imageData map of image file name to data
  80207. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80208. * @returns glTF PBR Metallic Roughness factors
  80209. */
  80210. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  80211. private _getGLTFTextureSampler;
  80212. private _getGLTFTextureWrapMode;
  80213. private _getGLTFTextureWrapModesSampler;
  80214. /**
  80215. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  80216. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  80217. * @param mimeType mime type to use for the textures
  80218. * @param images array of glTF image interfaces
  80219. * @param textures array of glTF texture interfaces
  80220. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  80221. * @param imageData map of image file name to data
  80222. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80223. * @returns glTF PBR Metallic Roughness factors
  80224. */
  80225. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  80226. /**
  80227. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  80228. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  80229. * @param mimeType mime type to use for the textures
  80230. * @param images array of glTF image interfaces
  80231. * @param textures array of glTF texture interfaces
  80232. * @param materials array of glTF material interfaces
  80233. * @param imageData map of image file name to data
  80234. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80235. */
  80236. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  80237. private setMetallicRoughnessPbrMaterial;
  80238. private getPixelsFromTexture;
  80239. /**
  80240. * Extracts a texture from a Babylon texture into file data and glTF data
  80241. * @param babylonTexture Babylon texture to extract
  80242. * @param mimeType Mime Type of the babylonTexture
  80243. * @return glTF texture info, or null if the texture format is not supported
  80244. */
  80245. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  80246. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  80247. /**
  80248. * Builds a texture from base64 string
  80249. * @param base64Texture base64 texture string
  80250. * @param baseTextureName Name to use for the texture
  80251. * @param mimeType image mime type for the texture
  80252. * @param images array of images
  80253. * @param textures array of textures
  80254. * @param imageData map of image data
  80255. * @returns glTF texture info, or null if the texture format is not supported
  80256. */
  80257. private _getTextureInfoFromBase64;
  80258. }
  80259. }
  80260. declare module BABYLON {
  80261. /**
  80262. * Class for holding and downloading glTF file data
  80263. */
  80264. export class GLTFData {
  80265. /**
  80266. * Object which contains the file name as the key and its data as the value
  80267. */
  80268. glTFFiles: {
  80269. [fileName: string]: string | Blob;
  80270. };
  80271. /**
  80272. * Initializes the glTF file object
  80273. */
  80274. constructor();
  80275. /**
  80276. * Downloads the glTF data as files based on their names and data
  80277. */
  80278. downloadFiles(): void;
  80279. }
  80280. }
  80281. declare module BABYLON {
  80282. /**
  80283. * Holds a collection of exporter options and parameters
  80284. */
  80285. export interface IExportOptions {
  80286. /**
  80287. * Function which indicates whether a babylon node should be exported or not
  80288. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  80289. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  80290. */
  80291. shouldExportNode?(node: Node): boolean;
  80292. /**
  80293. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  80294. * @param metadata source metadata to read from
  80295. * @returns the data to store to glTF node extras
  80296. */
  80297. metadataSelector?(metadata: any): any;
  80298. /**
  80299. * The sample rate to bake animation curves
  80300. */
  80301. animationSampleRate?: number;
  80302. /**
  80303. * Begin serialization without waiting for the scene to be ready
  80304. */
  80305. exportWithoutWaitingForScene?: boolean;
  80306. /**
  80307. * Indicates if coordinate system swapping root nodes should be included in export
  80308. */
  80309. includeCoordinateSystemConversionNodes?: boolean;
  80310. }
  80311. /**
  80312. * Class for generating glTF data from a Babylon scene.
  80313. */
  80314. export class GLTF2Export {
  80315. /**
  80316. * Exports the geometry of the scene to .gltf file format asynchronously
  80317. * @param scene Babylon scene with scene hierarchy information
  80318. * @param filePrefix File prefix to use when generating the glTF file
  80319. * @param options Exporter options
  80320. * @returns Returns an object with a .gltf file and associates texture names
  80321. * as keys and their data and paths as values
  80322. */
  80323. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  80324. private static _PreExportAsync;
  80325. private static _PostExportAsync;
  80326. /**
  80327. * Exports the geometry of the scene to .glb file format asychronously
  80328. * @param scene Babylon scene with scene hierarchy information
  80329. * @param filePrefix File prefix to use when generating glb file
  80330. * @param options Exporter options
  80331. * @returns Returns an object with a .glb filename as key and data as value
  80332. */
  80333. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  80334. }
  80335. }
  80336. declare module BABYLON.GLTF2.Exporter {
  80337. /**
  80338. * @hidden
  80339. */
  80340. export class _GLTFUtilities {
  80341. /**
  80342. * Creates a buffer view based on the supplied arguments
  80343. * @param bufferIndex index value of the specified buffer
  80344. * @param byteOffset byte offset value
  80345. * @param byteLength byte length of the bufferView
  80346. * @param byteStride byte distance between conequential elements
  80347. * @param name name of the buffer view
  80348. * @returns bufferView for glTF
  80349. */
  80350. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  80351. /**
  80352. * Creates an accessor based on the supplied arguments
  80353. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  80354. * @param name The name of the accessor
  80355. * @param type The type of the accessor
  80356. * @param componentType The datatype of components in the attribute
  80357. * @param count The number of attributes referenced by this accessor
  80358. * @param byteOffset The offset relative to the start of the bufferView in bytes
  80359. * @param min Minimum value of each component in this attribute
  80360. * @param max Maximum value of each component in this attribute
  80361. * @returns accessor for glTF
  80362. */
  80363. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  80364. /**
  80365. * Calculates the minimum and maximum values of an array of position floats
  80366. * @param positions Positions array of a mesh
  80367. * @param vertexStart Starting vertex offset to calculate min and max values
  80368. * @param vertexCount Number of vertices to check for min and max values
  80369. * @returns min number array and max number array
  80370. */
  80371. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  80372. min: number[];
  80373. max: number[];
  80374. };
  80375. /**
  80376. * Converts a new right-handed Vector3
  80377. * @param vector vector3 array
  80378. * @returns right-handed Vector3
  80379. */
  80380. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  80381. /**
  80382. * Converts a Vector3 to right-handed
  80383. * @param vector Vector3 to convert to right-handed
  80384. */
  80385. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  80386. /**
  80387. * Converts a three element number array to right-handed
  80388. * @param vector number array to convert to right-handed
  80389. */
  80390. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  80391. /**
  80392. * Converts a new right-handed Vector3
  80393. * @param vector vector3 array
  80394. * @returns right-handed Vector3
  80395. */
  80396. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  80397. /**
  80398. * Converts a Vector3 to right-handed
  80399. * @param vector Vector3 to convert to right-handed
  80400. */
  80401. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  80402. /**
  80403. * Converts a three element number array to right-handed
  80404. * @param vector number array to convert to right-handed
  80405. */
  80406. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  80407. /**
  80408. * Converts a Vector4 to right-handed
  80409. * @param vector Vector4 to convert to right-handed
  80410. */
  80411. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  80412. /**
  80413. * Converts a Vector4 to right-handed
  80414. * @param vector Vector4 to convert to right-handed
  80415. */
  80416. static _GetRightHandedArray4FromRef(vector: number[]): void;
  80417. /**
  80418. * Converts a Quaternion to right-handed
  80419. * @param quaternion Source quaternion to convert to right-handed
  80420. */
  80421. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  80422. /**
  80423. * Converts a Quaternion to right-handed
  80424. * @param quaternion Source quaternion to convert to right-handed
  80425. */
  80426. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  80427. static _NormalizeTangentFromRef(tangent: Vector4): void;
  80428. }
  80429. }
  80430. declare module BABYLON.GLTF2.Exporter {
  80431. /**
  80432. * Converts Babylon Scene into glTF 2.0.
  80433. * @hidden
  80434. */
  80435. export class _Exporter {
  80436. /**
  80437. * Stores the glTF to export
  80438. */
  80439. _glTF: IGLTF;
  80440. /**
  80441. * Stores all generated buffer views, which represents views into the main glTF buffer data
  80442. */
  80443. _bufferViews: IBufferView[];
  80444. /**
  80445. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  80446. */
  80447. _accessors: IAccessor[];
  80448. /**
  80449. * Stores all the generated nodes, which contains transform and/or mesh information per node
  80450. */
  80451. _nodes: INode[];
  80452. /**
  80453. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  80454. */
  80455. private _scenes;
  80456. /**
  80457. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  80458. */
  80459. private _meshes;
  80460. /**
  80461. * Stores all the generated material information, which represents the appearance of each primitive
  80462. */
  80463. _materials: IMaterial[];
  80464. _materialMap: {
  80465. [materialID: number]: number;
  80466. };
  80467. /**
  80468. * Stores all the generated texture information, which is referenced by glTF materials
  80469. */
  80470. _textures: ITexture[];
  80471. /**
  80472. * Stores all the generated image information, which is referenced by glTF textures
  80473. */
  80474. _images: IImage[];
  80475. /**
  80476. * Stores all the texture samplers
  80477. */
  80478. _samplers: ISampler[];
  80479. /**
  80480. * Stores all the generated animation samplers, which is referenced by glTF animations
  80481. */
  80482. /**
  80483. * Stores the animations for glTF models
  80484. */
  80485. private _animations;
  80486. /**
  80487. * Stores the total amount of bytes stored in the glTF buffer
  80488. */
  80489. private _totalByteLength;
  80490. /**
  80491. * Stores a reference to the Babylon scene containing the source geometry and material information
  80492. */
  80493. _babylonScene: Scene;
  80494. /**
  80495. * Stores a map of the image data, where the key is the file name and the value
  80496. * is the image data
  80497. */
  80498. _imageData: {
  80499. [fileName: string]: {
  80500. data: Uint8Array;
  80501. mimeType: ImageMimeType;
  80502. };
  80503. };
  80504. /**
  80505. * Stores a map of the unique id of a node to its index in the node array
  80506. */
  80507. _nodeMap: {
  80508. [key: number]: number;
  80509. };
  80510. /**
  80511. * Specifies if the source Babylon scene was left handed, and needed conversion.
  80512. */
  80513. _convertToRightHandedSystem: boolean;
  80514. /**
  80515. * Specifies if a Babylon node should be converted to right-handed on export
  80516. */
  80517. _convertToRightHandedSystemMap: {
  80518. [nodeId: number]: boolean;
  80519. };
  80520. _includeCoordinateSystemConversionNodes: boolean;
  80521. /**
  80522. * Baked animation sample rate
  80523. */
  80524. private _animationSampleRate;
  80525. private _options;
  80526. private _localEngine;
  80527. _glTFMaterialExporter: _GLTFMaterialExporter;
  80528. private _extensions;
  80529. private static _ExtensionNames;
  80530. private static _ExtensionFactories;
  80531. private _applyExtension;
  80532. private _applyExtensions;
  80533. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  80534. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  80535. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  80536. [key: number]: number;
  80537. }): Promise<Nullable<INode>>;
  80538. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  80539. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  80540. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  80541. private _forEachExtensions;
  80542. private _extensionsOnExporting;
  80543. /**
  80544. * Load glTF serializer extensions
  80545. */
  80546. private _loadExtensions;
  80547. /**
  80548. * Creates a glTF Exporter instance, which can accept optional exporter options
  80549. * @param babylonScene Babylon scene object
  80550. * @param options Options to modify the behavior of the exporter
  80551. */
  80552. constructor(babylonScene: Scene, options?: IExportOptions);
  80553. dispose(): void;
  80554. /**
  80555. * Registers a glTF exporter extension
  80556. * @param name Name of the extension to export
  80557. * @param factory The factory function that creates the exporter extension
  80558. */
  80559. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  80560. /**
  80561. * Un-registers an exporter extension
  80562. * @param name The name fo the exporter extension
  80563. * @returns A boolean indicating whether the extension has been un-registered
  80564. */
  80565. static UnregisterExtension(name: string): boolean;
  80566. /**
  80567. * Lazy load a local engine
  80568. */
  80569. _getLocalEngine(): Engine;
  80570. private reorderIndicesBasedOnPrimitiveMode;
  80571. /**
  80572. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  80573. * clock-wise during export to glTF
  80574. * @param submesh BabylonJS submesh
  80575. * @param primitiveMode Primitive mode of the mesh
  80576. * @param sideOrientation the winding order of the submesh
  80577. * @param vertexBufferKind The type of vertex attribute
  80578. * @param meshAttributeArray The vertex attribute data
  80579. * @param byteOffset The offset to the binary data
  80580. * @param binaryWriter The binary data for the glTF file
  80581. * @param convertToRightHandedSystem Converts the values to right-handed
  80582. */
  80583. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  80584. /**
  80585. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  80586. * clock-wise during export to glTF
  80587. * @param submesh BabylonJS submesh
  80588. * @param primitiveMode Primitive mode of the mesh
  80589. * @param sideOrientation the winding order of the submesh
  80590. * @param vertexBufferKind The type of vertex attribute
  80591. * @param meshAttributeArray The vertex attribute data
  80592. * @param byteOffset The offset to the binary data
  80593. * @param binaryWriter The binary data for the glTF file
  80594. * @param convertToRightHandedSystem Converts the values to right-handed
  80595. */
  80596. private reorderTriangleFillMode;
  80597. /**
  80598. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  80599. * clock-wise during export to glTF
  80600. * @param submesh BabylonJS submesh
  80601. * @param primitiveMode Primitive mode of the mesh
  80602. * @param sideOrientation the winding order of the submesh
  80603. * @param vertexBufferKind The type of vertex attribute
  80604. * @param meshAttributeArray The vertex attribute data
  80605. * @param byteOffset The offset to the binary data
  80606. * @param binaryWriter The binary data for the glTF file
  80607. * @param convertToRightHandedSystem Converts the values to right-handed
  80608. */
  80609. private reorderTriangleStripDrawMode;
  80610. /**
  80611. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  80612. * clock-wise during export to glTF
  80613. * @param submesh BabylonJS submesh
  80614. * @param primitiveMode Primitive mode of the mesh
  80615. * @param sideOrientation the winding order of the submesh
  80616. * @param vertexBufferKind The type of vertex attribute
  80617. * @param meshAttributeArray The vertex attribute data
  80618. * @param byteOffset The offset to the binary data
  80619. * @param binaryWriter The binary data for the glTF file
  80620. * @param convertToRightHandedSystem Converts the values to right-handed
  80621. */
  80622. private reorderTriangleFanMode;
  80623. /**
  80624. * Writes the vertex attribute data to binary
  80625. * @param vertices The vertices to write to the binary writer
  80626. * @param byteOffset The offset into the binary writer to overwrite binary data
  80627. * @param vertexAttributeKind The vertex attribute type
  80628. * @param meshAttributeArray The vertex attribute data
  80629. * @param binaryWriter The writer containing the binary data
  80630. * @param convertToRightHandedSystem Converts the values to right-handed
  80631. */
  80632. private writeVertexAttributeData;
  80633. /**
  80634. * Writes mesh attribute data to a data buffer
  80635. * Returns the bytelength of the data
  80636. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  80637. * @param meshAttributeArray Array containing the attribute data
  80638. * @param binaryWriter The buffer to write the binary data to
  80639. * @param indices Used to specify the order of the vertex data
  80640. * @param convertToRightHandedSystem Converts the values to right-handed
  80641. */
  80642. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  80643. /**
  80644. * Generates glTF json data
  80645. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  80646. * @param glTFPrefix Text to use when prefixing a glTF file
  80647. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  80648. * @returns json data as string
  80649. */
  80650. private generateJSON;
  80651. /**
  80652. * Generates data for .gltf and .bin files based on the glTF prefix string
  80653. * @param glTFPrefix Text to use when prefixing a glTF file
  80654. * @param dispose Dispose the exporter
  80655. * @returns GLTFData with glTF file data
  80656. */
  80657. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  80658. /**
  80659. * Creates a binary buffer for glTF
  80660. * @returns array buffer for binary data
  80661. */
  80662. private _generateBinaryAsync;
  80663. /**
  80664. * Pads the number to a multiple of 4
  80665. * @param num number to pad
  80666. * @returns padded number
  80667. */
  80668. private _getPadding;
  80669. /**
  80670. * @hidden
  80671. */
  80672. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  80673. /**
  80674. * Sets the TRS for each node
  80675. * @param node glTF Node for storing the transformation data
  80676. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  80677. * @param convertToRightHandedSystem Converts the values to right-handed
  80678. */
  80679. private setNodeTransformation;
  80680. private getVertexBufferFromMesh;
  80681. /**
  80682. * Creates a bufferview based on the vertices type for the Babylon mesh
  80683. * @param kind Indicates the type of vertices data
  80684. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  80685. * @param binaryWriter The buffer to write the bufferview data to
  80686. * @param convertToRightHandedSystem Converts the values to right-handed
  80687. */
  80688. private createBufferViewKind;
  80689. /**
  80690. * The primitive mode of the Babylon mesh
  80691. * @param babylonMesh The BabylonJS mesh
  80692. */
  80693. private getMeshPrimitiveMode;
  80694. /**
  80695. * Sets the primitive mode of the glTF mesh primitive
  80696. * @param meshPrimitive glTF mesh primitive
  80697. * @param primitiveMode The primitive mode
  80698. */
  80699. private setPrimitiveMode;
  80700. /**
  80701. * Sets the vertex attribute accessor based of the glTF mesh primitive
  80702. * @param meshPrimitive glTF mesh primitive
  80703. * @param attributeKind vertex attribute
  80704. * @returns boolean specifying if uv coordinates are present
  80705. */
  80706. private setAttributeKind;
  80707. /**
  80708. * Sets data for the primitive attributes of each submesh
  80709. * @param mesh glTF Mesh object to store the primitive attribute information
  80710. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  80711. * @param binaryWriter Buffer to write the attribute data to
  80712. * @param convertToRightHandedSystem Converts the values to right-handed
  80713. */
  80714. private setPrimitiveAttributesAsync;
  80715. /**
  80716. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  80717. * @param node The node to check
  80718. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  80719. */
  80720. private isBabylonCoordinateSystemConvertingNode;
  80721. /**
  80722. * Creates a glTF scene based on the array of meshes
  80723. * Returns the the total byte offset
  80724. * @param babylonScene Babylon scene to get the mesh data from
  80725. * @param binaryWriter Buffer to write binary data to
  80726. */
  80727. private createSceneAsync;
  80728. /**
  80729. * Creates a mapping of Node unique id to node index and handles animations
  80730. * @param babylonScene Babylon Scene
  80731. * @param nodes Babylon transform nodes
  80732. * @param binaryWriter Buffer to write binary data to
  80733. * @returns Node mapping of unique id to index
  80734. */
  80735. private createNodeMapAndAnimationsAsync;
  80736. /**
  80737. * Creates a glTF node from a Babylon mesh
  80738. * @param babylonMesh Source Babylon mesh
  80739. * @param binaryWriter Buffer for storing geometry data
  80740. * @param convertToRightHandedSystem Converts the values to right-handed
  80741. * @param nodeMap Node mapping of unique id to glTF node index
  80742. * @returns glTF node
  80743. */
  80744. private createNodeAsync;
  80745. }
  80746. /**
  80747. * @hidden
  80748. *
  80749. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  80750. */
  80751. export class _BinaryWriter {
  80752. /**
  80753. * Array buffer which stores all binary data
  80754. */
  80755. private _arrayBuffer;
  80756. /**
  80757. * View of the array buffer
  80758. */
  80759. private _dataView;
  80760. /**
  80761. * byte offset of data in array buffer
  80762. */
  80763. private _byteOffset;
  80764. /**
  80765. * Initialize binary writer with an initial byte length
  80766. * @param byteLength Initial byte length of the array buffer
  80767. */
  80768. constructor(byteLength: number);
  80769. /**
  80770. * Resize the array buffer to the specified byte length
  80771. * @param byteLength
  80772. */
  80773. private resizeBuffer;
  80774. /**
  80775. * Get an array buffer with the length of the byte offset
  80776. * @returns ArrayBuffer resized to the byte offset
  80777. */
  80778. getArrayBuffer(): ArrayBuffer;
  80779. /**
  80780. * Get the byte offset of the array buffer
  80781. * @returns byte offset
  80782. */
  80783. getByteOffset(): number;
  80784. /**
  80785. * Stores an UInt8 in the array buffer
  80786. * @param entry
  80787. * @param byteOffset If defined, specifies where to set the value as an offset.
  80788. */
  80789. setUInt8(entry: number, byteOffset?: number): void;
  80790. /**
  80791. * Gets an UInt32 in the array buffer
  80792. * @param entry
  80793. * @param byteOffset If defined, specifies where to set the value as an offset.
  80794. */
  80795. getUInt32(byteOffset: number): number;
  80796. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  80797. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  80798. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  80799. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  80800. /**
  80801. * Stores a Float32 in the array buffer
  80802. * @param entry
  80803. */
  80804. setFloat32(entry: number, byteOffset?: number): void;
  80805. /**
  80806. * Stores an UInt32 in the array buffer
  80807. * @param entry
  80808. * @param byteOffset If defined, specifies where to set the value as an offset.
  80809. */
  80810. setUInt32(entry: number, byteOffset?: number): void;
  80811. }
  80812. }
  80813. declare module BABYLON.GLTF2.Exporter {
  80814. /**
  80815. * @hidden
  80816. * Interface to store animation data.
  80817. */
  80818. export interface _IAnimationData {
  80819. /**
  80820. * Keyframe data.
  80821. */
  80822. inputs: number[];
  80823. /**
  80824. * Value data.
  80825. */
  80826. outputs: number[][];
  80827. /**
  80828. * Animation interpolation data.
  80829. */
  80830. samplerInterpolation: AnimationSamplerInterpolation;
  80831. /**
  80832. * Minimum keyframe value.
  80833. */
  80834. inputsMin: number;
  80835. /**
  80836. * Maximum keyframe value.
  80837. */
  80838. inputsMax: number;
  80839. }
  80840. /**
  80841. * @hidden
  80842. */
  80843. export interface _IAnimationInfo {
  80844. /**
  80845. * The target channel for the animation
  80846. */
  80847. animationChannelTargetPath: AnimationChannelTargetPath;
  80848. /**
  80849. * The glTF accessor type for the data.
  80850. */
  80851. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  80852. /**
  80853. * Specifies if quaternions should be used.
  80854. */
  80855. useQuaternion: boolean;
  80856. }
  80857. /**
  80858. * @hidden
  80859. * Utility class for generating glTF animation data from BabylonJS.
  80860. */
  80861. export class _GLTFAnimation {
  80862. /**
  80863. * @ignore
  80864. *
  80865. * Creates glTF channel animation from BabylonJS animation.
  80866. * @param babylonTransformNode - BabylonJS mesh.
  80867. * @param animation - animation.
  80868. * @param animationChannelTargetPath - The target animation channel.
  80869. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  80870. * @param useQuaternion - Specifies if quaternions are used.
  80871. * @returns nullable IAnimationData
  80872. */
  80873. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  80874. private static _DeduceAnimationInfo;
  80875. /**
  80876. * @ignore
  80877. * Create node animations from the transform node animations
  80878. * @param babylonNode
  80879. * @param runtimeGLTFAnimation
  80880. * @param idleGLTFAnimations
  80881. * @param nodeMap
  80882. * @param nodes
  80883. * @param binaryWriter
  80884. * @param bufferViews
  80885. * @param accessors
  80886. * @param convertToRightHandedSystem
  80887. * @param animationSampleRate
  80888. */
  80889. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  80890. [key: number]: number;
  80891. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  80892. /**
  80893. * @ignore
  80894. * Create node animations from the animation groups
  80895. * @param babylonScene
  80896. * @param glTFAnimations
  80897. * @param nodeMap
  80898. * @param nodes
  80899. * @param binaryWriter
  80900. * @param bufferViews
  80901. * @param accessors
  80902. * @param convertToRightHandedSystemMap
  80903. * @param animationSampleRate
  80904. */
  80905. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  80906. [key: number]: number;
  80907. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  80908. [nodeId: number]: boolean;
  80909. }, animationSampleRate: number): void;
  80910. private static AddAnimation;
  80911. /**
  80912. * Create a baked animation
  80913. * @param babylonTransformNode BabylonJS mesh
  80914. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  80915. * @param animationChannelTargetPath animation target channel
  80916. * @param minFrame minimum animation frame
  80917. * @param maxFrame maximum animation frame
  80918. * @param fps frames per second of the animation
  80919. * @param inputs input key frames of the animation
  80920. * @param outputs output key frame data of the animation
  80921. * @param convertToRightHandedSystem converts the values to right-handed
  80922. * @param useQuaternion specifies if quaternions should be used
  80923. */
  80924. private static _CreateBakedAnimation;
  80925. private static _ConvertFactorToVector3OrQuaternion;
  80926. private static _SetInterpolatedValue;
  80927. /**
  80928. * Creates linear animation from the animation key frames
  80929. * @param babylonTransformNode BabylonJS mesh
  80930. * @param animation BabylonJS animation
  80931. * @param animationChannelTargetPath The target animation channel
  80932. * @param frameDelta The difference between the last and first frame of the animation
  80933. * @param inputs Array to store the key frame times
  80934. * @param outputs Array to store the key frame data
  80935. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  80936. * @param useQuaternion Specifies if quaternions are used in the animation
  80937. */
  80938. private static _CreateLinearOrStepAnimation;
  80939. /**
  80940. * Creates cubic spline animation from the animation key frames
  80941. * @param babylonTransformNode BabylonJS mesh
  80942. * @param animation BabylonJS animation
  80943. * @param animationChannelTargetPath The target animation channel
  80944. * @param frameDelta The difference between the last and first frame of the animation
  80945. * @param inputs Array to store the key frame times
  80946. * @param outputs Array to store the key frame data
  80947. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  80948. * @param useQuaternion Specifies if quaternions are used in the animation
  80949. */
  80950. private static _CreateCubicSplineAnimation;
  80951. private static _GetBasePositionRotationOrScale;
  80952. /**
  80953. * Adds a key frame value
  80954. * @param keyFrame
  80955. * @param animation
  80956. * @param outputs
  80957. * @param animationChannelTargetPath
  80958. * @param basePositionRotationOrScale
  80959. * @param convertToRightHandedSystem
  80960. * @param useQuaternion
  80961. */
  80962. private static _AddKeyframeValue;
  80963. /**
  80964. * Determine the interpolation based on the key frames
  80965. * @param keyFrames
  80966. * @param animationChannelTargetPath
  80967. * @param useQuaternion
  80968. */
  80969. private static _DeduceInterpolation;
  80970. /**
  80971. * Adds an input tangent or output tangent to the output data
  80972. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  80973. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  80974. * @param outputs The animation data by keyframe
  80975. * @param animationChannelTargetPath The target animation channel
  80976. * @param interpolation The interpolation type
  80977. * @param keyFrame The key frame with the animation data
  80978. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  80979. * @param useQuaternion Specifies if quaternions are used
  80980. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  80981. */
  80982. private static AddSplineTangent;
  80983. /**
  80984. * Get the minimum and maximum key frames' frame values
  80985. * @param keyFrames animation key frames
  80986. * @returns the minimum and maximum key frame value
  80987. */
  80988. private static calculateMinMaxKeyFrames;
  80989. }
  80990. }
  80991. declare module BABYLON.GLTF2.Exporter {
  80992. /** @hidden */
  80993. export var textureTransformPixelShader: {
  80994. name: string;
  80995. shader: string;
  80996. };
  80997. }
  80998. declare module BABYLON.GLTF2.Exporter.Extensions {
  80999. /**
  81000. * @hidden
  81001. */
  81002. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  81003. private _recordedTextures;
  81004. /** Name of this extension */
  81005. readonly name: string;
  81006. /** Defines whether this extension is enabled */
  81007. enabled: boolean;
  81008. /** Defines whether this extension is required */
  81009. required: boolean;
  81010. /** Reference to the glTF exporter */
  81011. private _wasUsed;
  81012. constructor(exporter: _Exporter);
  81013. dispose(): void;
  81014. /** @hidden */
  81015. get wasUsed(): boolean;
  81016. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  81017. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  81018. /**
  81019. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  81020. * @param babylonTexture
  81021. * @param offset
  81022. * @param rotation
  81023. * @param scale
  81024. * @param scene
  81025. */
  81026. private _textureTransformTextureAsync;
  81027. }
  81028. }
  81029. declare module BABYLON.GLTF2.Exporter.Extensions {
  81030. /**
  81031. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  81032. */
  81033. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  81034. /** The name of this extension. */
  81035. readonly name: string;
  81036. /** Defines whether this extension is enabled. */
  81037. enabled: boolean;
  81038. /** Defines whether this extension is required */
  81039. required: boolean;
  81040. /** Reference to the glTF exporter */
  81041. private _exporter;
  81042. private _lights;
  81043. /** @hidden */
  81044. constructor(exporter: _Exporter);
  81045. /** @hidden */
  81046. dispose(): void;
  81047. /** @hidden */
  81048. get wasUsed(): boolean;
  81049. /** @hidden */
  81050. onExporting(): void;
  81051. /**
  81052. * Define this method to modify the default behavior when exporting a node
  81053. * @param context The context when exporting the node
  81054. * @param node glTF node
  81055. * @param babylonNode BabylonJS node
  81056. * @param nodeMap Node mapping of unique id to glTF node index
  81057. * @returns nullable INode promise
  81058. */
  81059. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  81060. [key: number]: number;
  81061. }): Promise<Nullable<INode>>;
  81062. }
  81063. }
  81064. declare module BABYLON.GLTF2.Exporter.Extensions {
  81065. /**
  81066. * @hidden
  81067. */
  81068. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  81069. /** Name of this extension */
  81070. readonly name: string;
  81071. /** Defines whether this extension is enabled */
  81072. enabled: boolean;
  81073. /** Defines whether this extension is required */
  81074. required: boolean;
  81075. /** Reference to the glTF exporter */
  81076. private _textureInfos;
  81077. private _exportedTextures;
  81078. private _wasUsed;
  81079. constructor(exporter: _Exporter);
  81080. dispose(): void;
  81081. /** @hidden */
  81082. get wasUsed(): boolean;
  81083. private _getTextureIndex;
  81084. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  81085. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  81086. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  81087. }
  81088. }
  81089. declare module BABYLON {
  81090. /**
  81091. * Class for generating STL data from a Babylon scene.
  81092. */
  81093. export class STLExport {
  81094. /**
  81095. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  81096. * @param meshes list defines the mesh to serialize
  81097. * @param download triggers the automatic download of the file.
  81098. * @param fileName changes the downloads fileName.
  81099. * @param binary changes the STL to a binary type.
  81100. * @param isLittleEndian toggle for binary type exporter.
  81101. * @returns the STL as UTF8 string
  81102. */
  81103. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  81104. }
  81105. }
  81106. declare module "babylonjs-gltf2interface" {
  81107. export = BABYLON.GLTF2;
  81108. }
  81109. /**
  81110. * Module for glTF 2.0 Interface
  81111. */
  81112. declare module BABYLON.GLTF2 {
  81113. /**
  81114. * The datatype of the components in the attribute
  81115. */
  81116. const enum AccessorComponentType {
  81117. /**
  81118. * Byte
  81119. */
  81120. BYTE = 5120,
  81121. /**
  81122. * Unsigned Byte
  81123. */
  81124. UNSIGNED_BYTE = 5121,
  81125. /**
  81126. * Short
  81127. */
  81128. SHORT = 5122,
  81129. /**
  81130. * Unsigned Short
  81131. */
  81132. UNSIGNED_SHORT = 5123,
  81133. /**
  81134. * Unsigned Int
  81135. */
  81136. UNSIGNED_INT = 5125,
  81137. /**
  81138. * Float
  81139. */
  81140. FLOAT = 5126,
  81141. }
  81142. /**
  81143. * Specifies if the attirbute is a scalar, vector, or matrix
  81144. */
  81145. const enum AccessorType {
  81146. /**
  81147. * Scalar
  81148. */
  81149. SCALAR = "SCALAR",
  81150. /**
  81151. * Vector2
  81152. */
  81153. VEC2 = "VEC2",
  81154. /**
  81155. * Vector3
  81156. */
  81157. VEC3 = "VEC3",
  81158. /**
  81159. * Vector4
  81160. */
  81161. VEC4 = "VEC4",
  81162. /**
  81163. * Matrix2x2
  81164. */
  81165. MAT2 = "MAT2",
  81166. /**
  81167. * Matrix3x3
  81168. */
  81169. MAT3 = "MAT3",
  81170. /**
  81171. * Matrix4x4
  81172. */
  81173. MAT4 = "MAT4",
  81174. }
  81175. /**
  81176. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  81177. */
  81178. const enum AnimationChannelTargetPath {
  81179. /**
  81180. * Translation
  81181. */
  81182. TRANSLATION = "translation",
  81183. /**
  81184. * Rotation
  81185. */
  81186. ROTATION = "rotation",
  81187. /**
  81188. * Scale
  81189. */
  81190. SCALE = "scale",
  81191. /**
  81192. * Weights
  81193. */
  81194. WEIGHTS = "weights",
  81195. }
  81196. /**
  81197. * Interpolation algorithm
  81198. */
  81199. const enum AnimationSamplerInterpolation {
  81200. /**
  81201. * The animated values are linearly interpolated between keyframes
  81202. */
  81203. LINEAR = "LINEAR",
  81204. /**
  81205. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  81206. */
  81207. STEP = "STEP",
  81208. /**
  81209. * The animation's interpolation is computed using a cubic spline with specified tangents
  81210. */
  81211. CUBICSPLINE = "CUBICSPLINE",
  81212. }
  81213. /**
  81214. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  81215. */
  81216. const enum CameraType {
  81217. /**
  81218. * A perspective camera containing properties to create a perspective projection matrix
  81219. */
  81220. PERSPECTIVE = "perspective",
  81221. /**
  81222. * An orthographic camera containing properties to create an orthographic projection matrix
  81223. */
  81224. ORTHOGRAPHIC = "orthographic",
  81225. }
  81226. /**
  81227. * The mime-type of the image
  81228. */
  81229. const enum ImageMimeType {
  81230. /**
  81231. * JPEG Mime-type
  81232. */
  81233. JPEG = "image/jpeg",
  81234. /**
  81235. * PNG Mime-type
  81236. */
  81237. PNG = "image/png",
  81238. }
  81239. /**
  81240. * The alpha rendering mode of the material
  81241. */
  81242. const enum MaterialAlphaMode {
  81243. /**
  81244. * The alpha value is ignored and the rendered output is fully opaque
  81245. */
  81246. OPAQUE = "OPAQUE",
  81247. /**
  81248. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  81249. */
  81250. MASK = "MASK",
  81251. /**
  81252. * 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)
  81253. */
  81254. BLEND = "BLEND",
  81255. }
  81256. /**
  81257. * The type of the primitives to render
  81258. */
  81259. const enum MeshPrimitiveMode {
  81260. /**
  81261. * Points
  81262. */
  81263. POINTS = 0,
  81264. /**
  81265. * Lines
  81266. */
  81267. LINES = 1,
  81268. /**
  81269. * Line Loop
  81270. */
  81271. LINE_LOOP = 2,
  81272. /**
  81273. * Line Strip
  81274. */
  81275. LINE_STRIP = 3,
  81276. /**
  81277. * Triangles
  81278. */
  81279. TRIANGLES = 4,
  81280. /**
  81281. * Triangle Strip
  81282. */
  81283. TRIANGLE_STRIP = 5,
  81284. /**
  81285. * Triangle Fan
  81286. */
  81287. TRIANGLE_FAN = 6,
  81288. }
  81289. /**
  81290. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  81291. */
  81292. const enum TextureMagFilter {
  81293. /**
  81294. * Nearest
  81295. */
  81296. NEAREST = 9728,
  81297. /**
  81298. * Linear
  81299. */
  81300. LINEAR = 9729,
  81301. }
  81302. /**
  81303. * Minification filter. All valid values correspond to WebGL enums
  81304. */
  81305. const enum TextureMinFilter {
  81306. /**
  81307. * Nearest
  81308. */
  81309. NEAREST = 9728,
  81310. /**
  81311. * Linear
  81312. */
  81313. LINEAR = 9729,
  81314. /**
  81315. * Nearest Mip-Map Nearest
  81316. */
  81317. NEAREST_MIPMAP_NEAREST = 9984,
  81318. /**
  81319. * Linear Mipmap Nearest
  81320. */
  81321. LINEAR_MIPMAP_NEAREST = 9985,
  81322. /**
  81323. * Nearest Mipmap Linear
  81324. */
  81325. NEAREST_MIPMAP_LINEAR = 9986,
  81326. /**
  81327. * Linear Mipmap Linear
  81328. */
  81329. LINEAR_MIPMAP_LINEAR = 9987,
  81330. }
  81331. /**
  81332. * S (U) wrapping mode. All valid values correspond to WebGL enums
  81333. */
  81334. const enum TextureWrapMode {
  81335. /**
  81336. * Clamp to Edge
  81337. */
  81338. CLAMP_TO_EDGE = 33071,
  81339. /**
  81340. * Mirrored Repeat
  81341. */
  81342. MIRRORED_REPEAT = 33648,
  81343. /**
  81344. * Repeat
  81345. */
  81346. REPEAT = 10497,
  81347. }
  81348. /**
  81349. * glTF Property
  81350. */
  81351. interface IProperty {
  81352. /**
  81353. * Dictionary object with extension-specific objects
  81354. */
  81355. extensions?: {
  81356. [key: string]: any;
  81357. };
  81358. /**
  81359. * Application-Specific data
  81360. */
  81361. extras?: any;
  81362. }
  81363. /**
  81364. * glTF Child of Root Property
  81365. */
  81366. interface IChildRootProperty extends IProperty {
  81367. /**
  81368. * The user-defined name of this object
  81369. */
  81370. name?: string;
  81371. }
  81372. /**
  81373. * Indices of those attributes that deviate from their initialization value
  81374. */
  81375. interface IAccessorSparseIndices extends IProperty {
  81376. /**
  81377. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  81378. */
  81379. bufferView: number;
  81380. /**
  81381. * The offset relative to the start of the bufferView in bytes. Must be aligned
  81382. */
  81383. byteOffset?: number;
  81384. /**
  81385. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  81386. */
  81387. componentType: AccessorComponentType;
  81388. }
  81389. /**
  81390. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  81391. */
  81392. interface IAccessorSparseValues extends IProperty {
  81393. /**
  81394. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  81395. */
  81396. bufferView: number;
  81397. /**
  81398. * The offset relative to the start of the bufferView in bytes. Must be aligned
  81399. */
  81400. byteOffset?: number;
  81401. }
  81402. /**
  81403. * Sparse storage of attributes that deviate from their initialization value
  81404. */
  81405. interface IAccessorSparse extends IProperty {
  81406. /**
  81407. * The number of attributes encoded in this sparse accessor
  81408. */
  81409. count: number;
  81410. /**
  81411. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  81412. */
  81413. indices: IAccessorSparseIndices;
  81414. /**
  81415. * 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
  81416. */
  81417. values: IAccessorSparseValues;
  81418. }
  81419. /**
  81420. * 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
  81421. */
  81422. interface IAccessor extends IChildRootProperty {
  81423. /**
  81424. * The index of the bufferview
  81425. */
  81426. bufferView?: number;
  81427. /**
  81428. * The offset relative to the start of the bufferView in bytes
  81429. */
  81430. byteOffset?: number;
  81431. /**
  81432. * The datatype of components in the attribute
  81433. */
  81434. componentType: AccessorComponentType;
  81435. /**
  81436. * Specifies whether integer data values should be normalized
  81437. */
  81438. normalized?: boolean;
  81439. /**
  81440. * The number of attributes referenced by this accessor
  81441. */
  81442. count: number;
  81443. /**
  81444. * Specifies if the attribute is a scalar, vector, or matrix
  81445. */
  81446. type: AccessorType;
  81447. /**
  81448. * Maximum value of each component in this attribute
  81449. */
  81450. max?: number[];
  81451. /**
  81452. * Minimum value of each component in this attribute
  81453. */
  81454. min?: number[];
  81455. /**
  81456. * Sparse storage of attributes that deviate from their initialization value
  81457. */
  81458. sparse?: IAccessorSparse;
  81459. }
  81460. /**
  81461. * Targets an animation's sampler at a node's property
  81462. */
  81463. interface IAnimationChannel extends IProperty {
  81464. /**
  81465. * The index of a sampler in this animation used to compute the value for the target
  81466. */
  81467. sampler: number;
  81468. /**
  81469. * The index of the node and TRS property to target
  81470. */
  81471. target: IAnimationChannelTarget;
  81472. }
  81473. /**
  81474. * The index of the node and TRS property that an animation channel targets
  81475. */
  81476. interface IAnimationChannelTarget extends IProperty {
  81477. /**
  81478. * The index of the node to target
  81479. */
  81480. node: number;
  81481. /**
  81482. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  81483. */
  81484. path: AnimationChannelTargetPath;
  81485. }
  81486. /**
  81487. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  81488. */
  81489. interface IAnimationSampler extends IProperty {
  81490. /**
  81491. * The index of an accessor containing keyframe input values, e.g., time
  81492. */
  81493. input: number;
  81494. /**
  81495. * Interpolation algorithm
  81496. */
  81497. interpolation?: AnimationSamplerInterpolation;
  81498. /**
  81499. * The index of an accessor, containing keyframe output values
  81500. */
  81501. output: number;
  81502. }
  81503. /**
  81504. * A keyframe animation
  81505. */
  81506. interface IAnimation extends IChildRootProperty {
  81507. /**
  81508. * An array of channels, each of which targets an animation's sampler at a node's property
  81509. */
  81510. channels: IAnimationChannel[];
  81511. /**
  81512. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  81513. */
  81514. samplers: IAnimationSampler[];
  81515. }
  81516. /**
  81517. * Metadata about the glTF asset
  81518. */
  81519. interface IAsset extends IChildRootProperty {
  81520. /**
  81521. * A copyright message suitable for display to credit the content creator
  81522. */
  81523. copyright?: string;
  81524. /**
  81525. * Tool that generated this glTF model. Useful for debugging
  81526. */
  81527. generator?: string;
  81528. /**
  81529. * The glTF version that this asset targets
  81530. */
  81531. version: string;
  81532. /**
  81533. * The minimum glTF version that this asset targets
  81534. */
  81535. minVersion?: string;
  81536. }
  81537. /**
  81538. * A buffer points to binary geometry, animation, or skins
  81539. */
  81540. interface IBuffer extends IChildRootProperty {
  81541. /**
  81542. * 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
  81543. */
  81544. uri?: string;
  81545. /**
  81546. * The length of the buffer in bytes
  81547. */
  81548. byteLength: number;
  81549. }
  81550. /**
  81551. * A view into a buffer generally representing a subset of the buffer
  81552. */
  81553. interface IBufferView extends IChildRootProperty {
  81554. /**
  81555. * The index of the buffer
  81556. */
  81557. buffer: number;
  81558. /**
  81559. * The offset into the buffer in bytes
  81560. */
  81561. byteOffset?: number;
  81562. /**
  81563. * The lenth of the bufferView in bytes
  81564. */
  81565. byteLength: number;
  81566. /**
  81567. * The stride, in bytes
  81568. */
  81569. byteStride?: number;
  81570. }
  81571. /**
  81572. * An orthographic camera containing properties to create an orthographic projection matrix
  81573. */
  81574. interface ICameraOrthographic extends IProperty {
  81575. /**
  81576. * The floating-point horizontal magnification of the view. Must not be zero
  81577. */
  81578. xmag: number;
  81579. /**
  81580. * The floating-point vertical magnification of the view. Must not be zero
  81581. */
  81582. ymag: number;
  81583. /**
  81584. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  81585. */
  81586. zfar: number;
  81587. /**
  81588. * The floating-point distance to the near clipping plane
  81589. */
  81590. znear: number;
  81591. }
  81592. /**
  81593. * A perspective camera containing properties to create a perspective projection matrix
  81594. */
  81595. interface ICameraPerspective extends IProperty {
  81596. /**
  81597. * The floating-point aspect ratio of the field of view
  81598. */
  81599. aspectRatio?: number;
  81600. /**
  81601. * The floating-point vertical field of view in radians
  81602. */
  81603. yfov: number;
  81604. /**
  81605. * The floating-point distance to the far clipping plane
  81606. */
  81607. zfar?: number;
  81608. /**
  81609. * The floating-point distance to the near clipping plane
  81610. */
  81611. znear: number;
  81612. }
  81613. /**
  81614. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  81615. */
  81616. interface ICamera extends IChildRootProperty {
  81617. /**
  81618. * An orthographic camera containing properties to create an orthographic projection matrix
  81619. */
  81620. orthographic?: ICameraOrthographic;
  81621. /**
  81622. * A perspective camera containing properties to create a perspective projection matrix
  81623. */
  81624. perspective?: ICameraPerspective;
  81625. /**
  81626. * Specifies if the camera uses a perspective or orthographic projection
  81627. */
  81628. type: CameraType;
  81629. }
  81630. /**
  81631. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  81632. */
  81633. interface IImage extends IChildRootProperty {
  81634. /**
  81635. * 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
  81636. */
  81637. uri?: string;
  81638. /**
  81639. * The image's MIME type
  81640. */
  81641. mimeType?: ImageMimeType;
  81642. /**
  81643. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  81644. */
  81645. bufferView?: number;
  81646. }
  81647. /**
  81648. * Material Normal Texture Info
  81649. */
  81650. interface IMaterialNormalTextureInfo extends ITextureInfo {
  81651. /**
  81652. * The scalar multiplier applied to each normal vector of the normal texture
  81653. */
  81654. scale?: number;
  81655. }
  81656. /**
  81657. * Material Occlusion Texture Info
  81658. */
  81659. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  81660. /**
  81661. * A scalar multiplier controlling the amount of occlusion applied
  81662. */
  81663. strength?: number;
  81664. }
  81665. /**
  81666. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  81667. */
  81668. interface IMaterialPbrMetallicRoughness {
  81669. /**
  81670. * The material's base color factor
  81671. */
  81672. baseColorFactor?: number[];
  81673. /**
  81674. * The base color texture
  81675. */
  81676. baseColorTexture?: ITextureInfo;
  81677. /**
  81678. * The metalness of the material
  81679. */
  81680. metallicFactor?: number;
  81681. /**
  81682. * The roughness of the material
  81683. */
  81684. roughnessFactor?: number;
  81685. /**
  81686. * The metallic-roughness texture
  81687. */
  81688. metallicRoughnessTexture?: ITextureInfo;
  81689. }
  81690. /**
  81691. * The material appearance of a primitive
  81692. */
  81693. interface IMaterial extends IChildRootProperty {
  81694. /**
  81695. * 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
  81696. */
  81697. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  81698. /**
  81699. * The normal map texture
  81700. */
  81701. normalTexture?: IMaterialNormalTextureInfo;
  81702. /**
  81703. * The occlusion map texture
  81704. */
  81705. occlusionTexture?: IMaterialOcclusionTextureInfo;
  81706. /**
  81707. * The emissive map texture
  81708. */
  81709. emissiveTexture?: ITextureInfo;
  81710. /**
  81711. * 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
  81712. */
  81713. emissiveFactor?: number[];
  81714. /**
  81715. * The alpha rendering mode of the material
  81716. */
  81717. alphaMode?: MaterialAlphaMode;
  81718. /**
  81719. * The alpha cutoff value of the material
  81720. */
  81721. alphaCutoff?: number;
  81722. /**
  81723. * Specifies whether the material is double sided
  81724. */
  81725. doubleSided?: boolean;
  81726. }
  81727. /**
  81728. * Geometry to be rendered with the given material
  81729. */
  81730. interface IMeshPrimitive extends IProperty {
  81731. /**
  81732. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  81733. */
  81734. attributes: {
  81735. [name: string]: number;
  81736. };
  81737. /**
  81738. * The index of the accessor that contains the indices
  81739. */
  81740. indices?: number;
  81741. /**
  81742. * The index of the material to apply to this primitive when rendering
  81743. */
  81744. material?: number;
  81745. /**
  81746. * The type of primitives to render. All valid values correspond to WebGL enums
  81747. */
  81748. mode?: MeshPrimitiveMode;
  81749. /**
  81750. * 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
  81751. */
  81752. targets?: {
  81753. [name: string]: number;
  81754. }[];
  81755. }
  81756. /**
  81757. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  81758. */
  81759. interface IMesh extends IChildRootProperty {
  81760. /**
  81761. * An array of primitives, each defining geometry to be rendered with a material
  81762. */
  81763. primitives: IMeshPrimitive[];
  81764. /**
  81765. * Array of weights to be applied to the Morph Targets
  81766. */
  81767. weights?: number[];
  81768. }
  81769. /**
  81770. * A node in the node hierarchy
  81771. */
  81772. interface INode extends IChildRootProperty {
  81773. /**
  81774. * The index of the camera referenced by this node
  81775. */
  81776. camera?: number;
  81777. /**
  81778. * The indices of this node's children
  81779. */
  81780. children?: number[];
  81781. /**
  81782. * The index of the skin referenced by this node
  81783. */
  81784. skin?: number;
  81785. /**
  81786. * A floating-point 4x4 transformation matrix stored in column-major order
  81787. */
  81788. matrix?: number[];
  81789. /**
  81790. * The index of the mesh in this node
  81791. */
  81792. mesh?: number;
  81793. /**
  81794. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  81795. */
  81796. rotation?: number[];
  81797. /**
  81798. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  81799. */
  81800. scale?: number[];
  81801. /**
  81802. * The node's translation along the x, y, and z axes
  81803. */
  81804. translation?: number[];
  81805. /**
  81806. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  81807. */
  81808. weights?: number[];
  81809. }
  81810. /**
  81811. * Texture sampler properties for filtering and wrapping modes
  81812. */
  81813. interface ISampler extends IChildRootProperty {
  81814. /**
  81815. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  81816. */
  81817. magFilter?: TextureMagFilter;
  81818. /**
  81819. * Minification filter. All valid values correspond to WebGL enums
  81820. */
  81821. minFilter?: TextureMinFilter;
  81822. /**
  81823. * S (U) wrapping mode. All valid values correspond to WebGL enums
  81824. */
  81825. wrapS?: TextureWrapMode;
  81826. /**
  81827. * T (V) wrapping mode. All valid values correspond to WebGL enums
  81828. */
  81829. wrapT?: TextureWrapMode;
  81830. }
  81831. /**
  81832. * The root nodes of a scene
  81833. */
  81834. interface IScene extends IChildRootProperty {
  81835. /**
  81836. * The indices of each root node
  81837. */
  81838. nodes: number[];
  81839. }
  81840. /**
  81841. * Joints and matrices defining a skin
  81842. */
  81843. interface ISkin extends IChildRootProperty {
  81844. /**
  81845. * 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
  81846. */
  81847. inverseBindMatrices?: number;
  81848. /**
  81849. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  81850. */
  81851. skeleton?: number;
  81852. /**
  81853. * 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)
  81854. */
  81855. joints: number[];
  81856. }
  81857. /**
  81858. * A texture and its sampler
  81859. */
  81860. interface ITexture extends IChildRootProperty {
  81861. /**
  81862. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  81863. */
  81864. sampler?: number;
  81865. /**
  81866. * The index of the image used by this texture
  81867. */
  81868. source: number;
  81869. }
  81870. /**
  81871. * Reference to a texture
  81872. */
  81873. interface ITextureInfo extends IProperty {
  81874. /**
  81875. * The index of the texture
  81876. */
  81877. index: number;
  81878. /**
  81879. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  81880. */
  81881. texCoord?: number;
  81882. }
  81883. /**
  81884. * The root object for a glTF asset
  81885. */
  81886. interface IGLTF extends IProperty {
  81887. /**
  81888. * An array of accessors. An accessor is a typed view into a bufferView
  81889. */
  81890. accessors?: IAccessor[];
  81891. /**
  81892. * An array of keyframe animations
  81893. */
  81894. animations?: IAnimation[];
  81895. /**
  81896. * Metadata about the glTF asset
  81897. */
  81898. asset: IAsset;
  81899. /**
  81900. * An array of buffers. A buffer points to binary geometry, animation, or skins
  81901. */
  81902. buffers?: IBuffer[];
  81903. /**
  81904. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  81905. */
  81906. bufferViews?: IBufferView[];
  81907. /**
  81908. * An array of cameras
  81909. */
  81910. cameras?: ICamera[];
  81911. /**
  81912. * Names of glTF extensions used somewhere in this asset
  81913. */
  81914. extensionsUsed?: string[];
  81915. /**
  81916. * Names of glTF extensions required to properly load this asset
  81917. */
  81918. extensionsRequired?: string[];
  81919. /**
  81920. * An array of images. An image defines data used to create a texture
  81921. */
  81922. images?: IImage[];
  81923. /**
  81924. * An array of materials. A material defines the appearance of a primitive
  81925. */
  81926. materials?: IMaterial[];
  81927. /**
  81928. * An array of meshes. A mesh is a set of primitives to be rendered
  81929. */
  81930. meshes?: IMesh[];
  81931. /**
  81932. * An array of nodes
  81933. */
  81934. nodes?: INode[];
  81935. /**
  81936. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  81937. */
  81938. samplers?: ISampler[];
  81939. /**
  81940. * The index of the default scene
  81941. */
  81942. scene?: number;
  81943. /**
  81944. * An array of scenes
  81945. */
  81946. scenes?: IScene[];
  81947. /**
  81948. * An array of skins. A skin is defined by joints and matrices
  81949. */
  81950. skins?: ISkin[];
  81951. /**
  81952. * An array of textures
  81953. */
  81954. textures?: ITexture[];
  81955. }
  81956. /**
  81957. * The glTF validation results
  81958. * @ignore
  81959. */
  81960. interface IGLTFValidationResults {
  81961. info: {
  81962. generator: string;
  81963. hasAnimations: boolean;
  81964. hasDefaultScene: boolean;
  81965. hasMaterials: boolean;
  81966. hasMorphTargets: boolean;
  81967. hasSkins: boolean;
  81968. hasTextures: boolean;
  81969. maxAttributesUsed: number;
  81970. primitivesCount: number
  81971. };
  81972. issues: {
  81973. messages: Array<string>;
  81974. numErrors: number;
  81975. numHints: number;
  81976. numInfos: number;
  81977. numWarnings: number;
  81978. truncated: boolean
  81979. };
  81980. mimeType: string;
  81981. uri: string;
  81982. validatedAt: string;
  81983. validatorVersion: string;
  81984. }
  81985. /**
  81986. * The glTF validation options
  81987. */
  81988. interface IGLTFValidationOptions {
  81989. /** Uri to use */
  81990. uri?: string;
  81991. /** Function used to load external resources */
  81992. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  81993. /** Boolean indicating that we need to validate accessor data */
  81994. validateAccessorData?: boolean;
  81995. /** max number of issues allowed */
  81996. maxIssues?: number;
  81997. /** Ignored issues */
  81998. ignoredIssues?: Array<string>;
  81999. /** Value to override severy settings */
  82000. severityOverrides?: Object;
  82001. }
  82002. /**
  82003. * The glTF validator object
  82004. * @ignore
  82005. */
  82006. interface IGLTFValidator {
  82007. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  82008. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  82009. }
  82010. }
  82011. declare module BABYLON {
  82012. /** @hidden */
  82013. export var cellPixelShader: {
  82014. name: string;
  82015. shader: string;
  82016. };
  82017. }
  82018. declare module BABYLON {
  82019. /** @hidden */
  82020. export var cellVertexShader: {
  82021. name: string;
  82022. shader: string;
  82023. };
  82024. }
  82025. declare module BABYLON {
  82026. export class CellMaterial extends BABYLON.PushMaterial {
  82027. private _diffuseTexture;
  82028. diffuseTexture: BABYLON.BaseTexture;
  82029. diffuseColor: BABYLON.Color3;
  82030. _computeHighLevel: boolean;
  82031. computeHighLevel: boolean;
  82032. private _disableLighting;
  82033. disableLighting: boolean;
  82034. private _maxSimultaneousLights;
  82035. maxSimultaneousLights: number;
  82036. constructor(name: string, scene: BABYLON.Scene);
  82037. needAlphaBlending(): boolean;
  82038. needAlphaTesting(): boolean;
  82039. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82040. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82041. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82042. getAnimatables(): BABYLON.IAnimatable[];
  82043. getActiveTextures(): BABYLON.BaseTexture[];
  82044. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82045. dispose(forceDisposeEffect?: boolean): void;
  82046. getClassName(): string;
  82047. clone(name: string): CellMaterial;
  82048. serialize(): any;
  82049. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  82050. }
  82051. }
  82052. declare module BABYLON {
  82053. export class CustomShaderStructure {
  82054. FragmentStore: string;
  82055. VertexStore: string;
  82056. constructor();
  82057. }
  82058. export class ShaderSpecialParts {
  82059. constructor();
  82060. Fragment_Begin: string;
  82061. Fragment_Definitions: string;
  82062. Fragment_MainBegin: string;
  82063. Fragment_Custom_Diffuse: string;
  82064. Fragment_Before_Lights: string;
  82065. Fragment_Before_Fog: string;
  82066. Fragment_Custom_Alpha: string;
  82067. Fragment_Before_FragColor: string;
  82068. Vertex_Begin: string;
  82069. Vertex_Definitions: string;
  82070. Vertex_MainBegin: string;
  82071. Vertex_Before_PositionUpdated: string;
  82072. Vertex_Before_NormalUpdated: string;
  82073. Vertex_After_WorldPosComputed: string;
  82074. Vertex_MainEnd: string;
  82075. }
  82076. export class CustomMaterial extends BABYLON.StandardMaterial {
  82077. static ShaderIndexer: number;
  82078. CustomParts: ShaderSpecialParts;
  82079. _isCreatedShader: boolean;
  82080. _createdShaderName: string;
  82081. _customUniform: string[];
  82082. _newUniforms: string[];
  82083. _newUniformInstances: {
  82084. [name: string]: any;
  82085. };
  82086. _newSamplerInstances: {
  82087. [name: string]: BABYLON.Texture;
  82088. };
  82089. _customAttributes: string[];
  82090. FragmentShader: string;
  82091. VertexShader: string;
  82092. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  82093. ReviewUniform(name: string, arr: string[]): string[];
  82094. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  82095. constructor(name: string, scene: BABYLON.Scene);
  82096. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  82097. AddAttribute(name: string): CustomMaterial;
  82098. Fragment_Begin(shaderPart: string): CustomMaterial;
  82099. Fragment_Definitions(shaderPart: string): CustomMaterial;
  82100. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  82101. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  82102. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  82103. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  82104. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  82105. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  82106. Vertex_Begin(shaderPart: string): CustomMaterial;
  82107. Vertex_Definitions(shaderPart: string): CustomMaterial;
  82108. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  82109. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  82110. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  82111. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  82112. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  82113. }
  82114. }
  82115. declare module BABYLON {
  82116. export class ShaderAlebdoParts {
  82117. constructor();
  82118. Fragment_Begin: string;
  82119. Fragment_Definitions: string;
  82120. Fragment_MainBegin: string;
  82121. Fragment_Custom_Albedo: string;
  82122. Fragment_Before_Lights: string;
  82123. Fragment_Custom_MetallicRoughness: string;
  82124. Fragment_Custom_MicroSurface: string;
  82125. Fragment_Before_Fog: string;
  82126. Fragment_Custom_Alpha: string;
  82127. Fragment_Before_FragColor: string;
  82128. Vertex_Begin: string;
  82129. Vertex_Definitions: string;
  82130. Vertex_MainBegin: string;
  82131. Vertex_Before_PositionUpdated: string;
  82132. Vertex_Before_NormalUpdated: string;
  82133. Vertex_After_WorldPosComputed: string;
  82134. Vertex_MainEnd: string;
  82135. }
  82136. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  82137. static ShaderIndexer: number;
  82138. CustomParts: ShaderAlebdoParts;
  82139. _isCreatedShader: boolean;
  82140. _createdShaderName: string;
  82141. _customUniform: string[];
  82142. _newUniforms: string[];
  82143. _newUniformInstances: {
  82144. [name: string]: any;
  82145. };
  82146. _newSamplerInstances: {
  82147. [name: string]: BABYLON.Texture;
  82148. };
  82149. _customAttributes: string[];
  82150. FragmentShader: string;
  82151. VertexShader: string;
  82152. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  82153. ReviewUniform(name: string, arr: string[]): string[];
  82154. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  82155. constructor(name: string, scene: BABYLON.Scene);
  82156. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  82157. AddAttribute(name: string): PBRCustomMaterial;
  82158. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  82159. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  82160. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  82161. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  82162. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  82163. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  82164. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  82165. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  82166. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  82167. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  82168. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  82169. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  82170. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  82171. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  82172. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  82173. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  82174. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  82175. }
  82176. }
  82177. declare module BABYLON {
  82178. /** @hidden */
  82179. export var firePixelShader: {
  82180. name: string;
  82181. shader: string;
  82182. };
  82183. }
  82184. declare module BABYLON {
  82185. /** @hidden */
  82186. export var fireVertexShader: {
  82187. name: string;
  82188. shader: string;
  82189. };
  82190. }
  82191. declare module BABYLON {
  82192. export class FireMaterial extends BABYLON.PushMaterial {
  82193. private _diffuseTexture;
  82194. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  82195. private _distortionTexture;
  82196. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  82197. private _opacityTexture;
  82198. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  82199. diffuseColor: BABYLON.Color3;
  82200. speed: number;
  82201. private _scaledDiffuse;
  82202. private _lastTime;
  82203. constructor(name: string, scene: BABYLON.Scene);
  82204. needAlphaBlending(): boolean;
  82205. needAlphaTesting(): boolean;
  82206. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82207. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82208. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82209. getAnimatables(): BABYLON.IAnimatable[];
  82210. getActiveTextures(): BABYLON.BaseTexture[];
  82211. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82212. getClassName(): string;
  82213. dispose(forceDisposeEffect?: boolean): void;
  82214. clone(name: string): FireMaterial;
  82215. serialize(): any;
  82216. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  82217. }
  82218. }
  82219. declare module BABYLON {
  82220. /** @hidden */
  82221. export var furPixelShader: {
  82222. name: string;
  82223. shader: string;
  82224. };
  82225. }
  82226. declare module BABYLON {
  82227. /** @hidden */
  82228. export var furVertexShader: {
  82229. name: string;
  82230. shader: string;
  82231. };
  82232. }
  82233. declare module BABYLON {
  82234. export class FurMaterial extends BABYLON.PushMaterial {
  82235. private _diffuseTexture;
  82236. diffuseTexture: BABYLON.BaseTexture;
  82237. private _heightTexture;
  82238. heightTexture: BABYLON.BaseTexture;
  82239. diffuseColor: BABYLON.Color3;
  82240. furLength: number;
  82241. furAngle: number;
  82242. furColor: BABYLON.Color3;
  82243. furOffset: number;
  82244. furSpacing: number;
  82245. furGravity: BABYLON.Vector3;
  82246. furSpeed: number;
  82247. furDensity: number;
  82248. furOcclusion: number;
  82249. furTexture: BABYLON.DynamicTexture;
  82250. private _disableLighting;
  82251. disableLighting: boolean;
  82252. private _maxSimultaneousLights;
  82253. maxSimultaneousLights: number;
  82254. highLevelFur: boolean;
  82255. _meshes: BABYLON.AbstractMesh[];
  82256. private _furTime;
  82257. constructor(name: string, scene: BABYLON.Scene);
  82258. get furTime(): number;
  82259. set furTime(furTime: number);
  82260. needAlphaBlending(): boolean;
  82261. needAlphaTesting(): boolean;
  82262. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82263. updateFur(): void;
  82264. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82265. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82266. getAnimatables(): BABYLON.IAnimatable[];
  82267. getActiveTextures(): BABYLON.BaseTexture[];
  82268. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82269. dispose(forceDisposeEffect?: boolean): void;
  82270. clone(name: string): FurMaterial;
  82271. serialize(): any;
  82272. getClassName(): string;
  82273. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  82274. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  82275. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  82276. }
  82277. }
  82278. declare module BABYLON {
  82279. /** @hidden */
  82280. export var gradientPixelShader: {
  82281. name: string;
  82282. shader: string;
  82283. };
  82284. }
  82285. declare module BABYLON {
  82286. /** @hidden */
  82287. export var gradientVertexShader: {
  82288. name: string;
  82289. shader: string;
  82290. };
  82291. }
  82292. declare module BABYLON {
  82293. export class GradientMaterial extends BABYLON.PushMaterial {
  82294. private _maxSimultaneousLights;
  82295. maxSimultaneousLights: number;
  82296. topColor: BABYLON.Color3;
  82297. topColorAlpha: number;
  82298. bottomColor: BABYLON.Color3;
  82299. bottomColorAlpha: number;
  82300. offset: number;
  82301. scale: number;
  82302. smoothness: number;
  82303. private _disableLighting;
  82304. disableLighting: boolean;
  82305. constructor(name: string, scene: BABYLON.Scene);
  82306. needAlphaBlending(): boolean;
  82307. needAlphaTesting(): boolean;
  82308. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82309. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82310. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82311. getAnimatables(): BABYLON.IAnimatable[];
  82312. dispose(forceDisposeEffect?: boolean): void;
  82313. clone(name: string): GradientMaterial;
  82314. serialize(): any;
  82315. getClassName(): string;
  82316. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  82317. }
  82318. }
  82319. declare module BABYLON {
  82320. /** @hidden */
  82321. export var gridPixelShader: {
  82322. name: string;
  82323. shader: string;
  82324. };
  82325. }
  82326. declare module BABYLON {
  82327. /** @hidden */
  82328. export var gridVertexShader: {
  82329. name: string;
  82330. shader: string;
  82331. };
  82332. }
  82333. declare module BABYLON {
  82334. /**
  82335. * The grid materials allows you to wrap any shape with a grid.
  82336. * Colors are customizable.
  82337. */
  82338. export class GridMaterial extends BABYLON.PushMaterial {
  82339. /**
  82340. * Main color of the grid (e.g. between lines)
  82341. */
  82342. mainColor: BABYLON.Color3;
  82343. /**
  82344. * Color of the grid lines.
  82345. */
  82346. lineColor: BABYLON.Color3;
  82347. /**
  82348. * The scale of the grid compared to unit.
  82349. */
  82350. gridRatio: number;
  82351. /**
  82352. * Allows setting an offset for the grid lines.
  82353. */
  82354. gridOffset: BABYLON.Vector3;
  82355. /**
  82356. * The frequency of thicker lines.
  82357. */
  82358. majorUnitFrequency: number;
  82359. /**
  82360. * The visibility of minor units in the grid.
  82361. */
  82362. minorUnitVisibility: number;
  82363. /**
  82364. * The grid opacity outside of the lines.
  82365. */
  82366. opacity: number;
  82367. /**
  82368. * Determine RBG output is premultiplied by alpha value.
  82369. */
  82370. preMultiplyAlpha: boolean;
  82371. private _opacityTexture;
  82372. opacityTexture: BABYLON.BaseTexture;
  82373. private _gridControl;
  82374. /**
  82375. * constructor
  82376. * @param name The name given to the material in order to identify it afterwards.
  82377. * @param scene The scene the material is used in.
  82378. */
  82379. constructor(name: string, scene: BABYLON.Scene);
  82380. /**
  82381. * Returns wehter or not the grid requires alpha blending.
  82382. */
  82383. needAlphaBlending(): boolean;
  82384. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  82385. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82386. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82387. /**
  82388. * Dispose the material and its associated resources.
  82389. * @param forceDisposeEffect will also dispose the used effect when true
  82390. */
  82391. dispose(forceDisposeEffect?: boolean): void;
  82392. clone(name: string): GridMaterial;
  82393. serialize(): any;
  82394. getClassName(): string;
  82395. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  82396. }
  82397. }
  82398. declare module BABYLON {
  82399. /** @hidden */
  82400. export var lavaPixelShader: {
  82401. name: string;
  82402. shader: string;
  82403. };
  82404. }
  82405. declare module BABYLON {
  82406. /** @hidden */
  82407. export var lavaVertexShader: {
  82408. name: string;
  82409. shader: string;
  82410. };
  82411. }
  82412. declare module BABYLON {
  82413. export class LavaMaterial extends BABYLON.PushMaterial {
  82414. private _diffuseTexture;
  82415. diffuseTexture: BABYLON.BaseTexture;
  82416. noiseTexture: BABYLON.BaseTexture;
  82417. fogColor: BABYLON.Color3;
  82418. speed: number;
  82419. movingSpeed: number;
  82420. lowFrequencySpeed: number;
  82421. fogDensity: number;
  82422. private _lastTime;
  82423. diffuseColor: BABYLON.Color3;
  82424. private _disableLighting;
  82425. disableLighting: boolean;
  82426. private _unlit;
  82427. unlit: boolean;
  82428. private _maxSimultaneousLights;
  82429. maxSimultaneousLights: number;
  82430. private _scaledDiffuse;
  82431. constructor(name: string, scene: BABYLON.Scene);
  82432. needAlphaBlending(): boolean;
  82433. needAlphaTesting(): boolean;
  82434. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82435. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82436. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82437. getAnimatables(): BABYLON.IAnimatable[];
  82438. getActiveTextures(): BABYLON.BaseTexture[];
  82439. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82440. dispose(forceDisposeEffect?: boolean): void;
  82441. clone(name: string): LavaMaterial;
  82442. serialize(): any;
  82443. getClassName(): string;
  82444. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  82445. }
  82446. }
  82447. declare module BABYLON {
  82448. /** @hidden */
  82449. export var mixPixelShader: {
  82450. name: string;
  82451. shader: string;
  82452. };
  82453. }
  82454. declare module BABYLON {
  82455. /** @hidden */
  82456. export var mixVertexShader: {
  82457. name: string;
  82458. shader: string;
  82459. };
  82460. }
  82461. declare module BABYLON {
  82462. export class MixMaterial extends BABYLON.PushMaterial {
  82463. /**
  82464. * Mix textures
  82465. */
  82466. private _mixTexture1;
  82467. mixTexture1: BABYLON.BaseTexture;
  82468. private _mixTexture2;
  82469. mixTexture2: BABYLON.BaseTexture;
  82470. /**
  82471. * Diffuse textures
  82472. */
  82473. private _diffuseTexture1;
  82474. diffuseTexture1: BABYLON.Texture;
  82475. private _diffuseTexture2;
  82476. diffuseTexture2: BABYLON.Texture;
  82477. private _diffuseTexture3;
  82478. diffuseTexture3: BABYLON.Texture;
  82479. private _diffuseTexture4;
  82480. diffuseTexture4: BABYLON.Texture;
  82481. private _diffuseTexture5;
  82482. diffuseTexture5: BABYLON.Texture;
  82483. private _diffuseTexture6;
  82484. diffuseTexture6: BABYLON.Texture;
  82485. private _diffuseTexture7;
  82486. diffuseTexture7: BABYLON.Texture;
  82487. private _diffuseTexture8;
  82488. diffuseTexture8: BABYLON.Texture;
  82489. /**
  82490. * Uniforms
  82491. */
  82492. diffuseColor: BABYLON.Color3;
  82493. specularColor: BABYLON.Color3;
  82494. specularPower: number;
  82495. private _disableLighting;
  82496. disableLighting: boolean;
  82497. private _maxSimultaneousLights;
  82498. maxSimultaneousLights: number;
  82499. constructor(name: string, scene: BABYLON.Scene);
  82500. needAlphaBlending(): boolean;
  82501. needAlphaTesting(): boolean;
  82502. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82503. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82504. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82505. getAnimatables(): BABYLON.IAnimatable[];
  82506. getActiveTextures(): BABYLON.BaseTexture[];
  82507. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82508. dispose(forceDisposeEffect?: boolean): void;
  82509. clone(name: string): MixMaterial;
  82510. serialize(): any;
  82511. getClassName(): string;
  82512. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  82513. }
  82514. }
  82515. declare module BABYLON {
  82516. /** @hidden */
  82517. export var normalPixelShader: {
  82518. name: string;
  82519. shader: string;
  82520. };
  82521. }
  82522. declare module BABYLON {
  82523. /** @hidden */
  82524. export var normalVertexShader: {
  82525. name: string;
  82526. shader: string;
  82527. };
  82528. }
  82529. declare module BABYLON {
  82530. export class NormalMaterial extends BABYLON.PushMaterial {
  82531. private _diffuseTexture;
  82532. diffuseTexture: BABYLON.BaseTexture;
  82533. diffuseColor: BABYLON.Color3;
  82534. private _disableLighting;
  82535. disableLighting: boolean;
  82536. private _maxSimultaneousLights;
  82537. maxSimultaneousLights: number;
  82538. constructor(name: string, scene: BABYLON.Scene);
  82539. needAlphaBlending(): boolean;
  82540. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  82541. needAlphaTesting(): boolean;
  82542. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82543. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82544. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82545. getAnimatables(): BABYLON.IAnimatable[];
  82546. getActiveTextures(): BABYLON.BaseTexture[];
  82547. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82548. dispose(forceDisposeEffect?: boolean): void;
  82549. clone(name: string): NormalMaterial;
  82550. serialize(): any;
  82551. getClassName(): string;
  82552. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  82553. }
  82554. }
  82555. declare module BABYLON {
  82556. /** @hidden */
  82557. export var shadowOnlyPixelShader: {
  82558. name: string;
  82559. shader: string;
  82560. };
  82561. }
  82562. declare module BABYLON {
  82563. /** @hidden */
  82564. export var shadowOnlyVertexShader: {
  82565. name: string;
  82566. shader: string;
  82567. };
  82568. }
  82569. declare module BABYLON {
  82570. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  82571. private _activeLight;
  82572. private _needAlphaBlending;
  82573. constructor(name: string, scene: BABYLON.Scene);
  82574. shadowColor: BABYLON.Color3;
  82575. needAlphaBlending(): boolean;
  82576. needAlphaTesting(): boolean;
  82577. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82578. get activeLight(): BABYLON.IShadowLight;
  82579. set activeLight(light: BABYLON.IShadowLight);
  82580. private _getFirstShadowLightForMesh;
  82581. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82582. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82583. clone(name: string): ShadowOnlyMaterial;
  82584. serialize(): any;
  82585. getClassName(): string;
  82586. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  82587. }
  82588. }
  82589. declare module BABYLON {
  82590. /** @hidden */
  82591. export var simplePixelShader: {
  82592. name: string;
  82593. shader: string;
  82594. };
  82595. }
  82596. declare module BABYLON {
  82597. /** @hidden */
  82598. export var simpleVertexShader: {
  82599. name: string;
  82600. shader: string;
  82601. };
  82602. }
  82603. declare module BABYLON {
  82604. export class SimpleMaterial extends BABYLON.PushMaterial {
  82605. private _diffuseTexture;
  82606. diffuseTexture: BABYLON.BaseTexture;
  82607. diffuseColor: BABYLON.Color3;
  82608. private _disableLighting;
  82609. disableLighting: boolean;
  82610. private _maxSimultaneousLights;
  82611. maxSimultaneousLights: number;
  82612. constructor(name: string, scene: BABYLON.Scene);
  82613. needAlphaBlending(): boolean;
  82614. needAlphaTesting(): boolean;
  82615. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82616. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82617. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82618. getAnimatables(): BABYLON.IAnimatable[];
  82619. getActiveTextures(): BABYLON.BaseTexture[];
  82620. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82621. dispose(forceDisposeEffect?: boolean): void;
  82622. clone(name: string): SimpleMaterial;
  82623. serialize(): any;
  82624. getClassName(): string;
  82625. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  82626. }
  82627. }
  82628. declare module BABYLON {
  82629. /** @hidden */
  82630. export var skyPixelShader: {
  82631. name: string;
  82632. shader: string;
  82633. };
  82634. }
  82635. declare module BABYLON {
  82636. /** @hidden */
  82637. export var skyVertexShader: {
  82638. name: string;
  82639. shader: string;
  82640. };
  82641. }
  82642. declare module BABYLON {
  82643. /**
  82644. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  82645. * @see https://doc.babylonjs.com/extensions/sky
  82646. */
  82647. export class SkyMaterial extends BABYLON.PushMaterial {
  82648. /**
  82649. * Defines the overall luminance of sky in interval ]0, 1[.
  82650. */
  82651. luminance: number;
  82652. /**
  82653. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  82654. */
  82655. turbidity: number;
  82656. /**
  82657. * Defines the sky appearance (light intensity).
  82658. */
  82659. rayleigh: number;
  82660. /**
  82661. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  82662. */
  82663. mieCoefficient: number;
  82664. /**
  82665. * Defines the amount of haze particles following the Mie scattering theory.
  82666. */
  82667. mieDirectionalG: number;
  82668. /**
  82669. * Defines the distance of the sun according to the active scene camera.
  82670. */
  82671. distance: number;
  82672. /**
  82673. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  82674. * "inclined".
  82675. */
  82676. inclination: number;
  82677. /**
  82678. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  82679. * an object direction and a reference direction.
  82680. */
  82681. azimuth: number;
  82682. /**
  82683. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  82684. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  82685. */
  82686. sunPosition: BABYLON.Vector3;
  82687. /**
  82688. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  82689. * .sunPosition property.
  82690. */
  82691. useSunPosition: boolean;
  82692. /**
  82693. * Defines an offset vector used to get a horizon offset.
  82694. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  82695. */
  82696. cameraOffset: BABYLON.Vector3;
  82697. private _cameraPosition;
  82698. /**
  82699. * Instantiates a new sky material.
  82700. * This material allows to create dynamic and texture free
  82701. * effects for skyboxes by taking care of the atmosphere state.
  82702. * @see https://doc.babylonjs.com/extensions/sky
  82703. * @param name Define the name of the material in the scene
  82704. * @param scene Define the scene the material belong to
  82705. */
  82706. constructor(name: string, scene: BABYLON.Scene);
  82707. /**
  82708. * Specifies if the material will require alpha blending
  82709. * @returns a boolean specifying if alpha blending is needed
  82710. */
  82711. needAlphaBlending(): boolean;
  82712. /**
  82713. * Specifies if this material should be rendered in alpha test mode
  82714. * @returns false as the sky material doesn't need alpha testing.
  82715. */
  82716. needAlphaTesting(): boolean;
  82717. /**
  82718. * Get the texture used for alpha test purpose.
  82719. * @returns null as the sky material has no texture.
  82720. */
  82721. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82722. /**
  82723. * Get if the submesh is ready to be used and all its information available.
  82724. * Child classes can use it to update shaders
  82725. * @param mesh defines the mesh to check
  82726. * @param subMesh defines which submesh to check
  82727. * @param useInstances specifies that instances should be used
  82728. * @returns a boolean indicating that the submesh is ready or not
  82729. */
  82730. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82731. /**
  82732. * Binds the submesh to this material by preparing the effect and shader to draw
  82733. * @param world defines the world transformation matrix
  82734. * @param mesh defines the mesh containing the submesh
  82735. * @param subMesh defines the submesh to bind the material to
  82736. */
  82737. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82738. /**
  82739. * Get the list of animatables in the material.
  82740. * @returns the list of animatables object used in the material
  82741. */
  82742. getAnimatables(): BABYLON.IAnimatable[];
  82743. /**
  82744. * Disposes the material
  82745. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  82746. */
  82747. dispose(forceDisposeEffect?: boolean): void;
  82748. /**
  82749. * Makes a duplicate of the material, and gives it a new name
  82750. * @param name defines the new name for the duplicated material
  82751. * @returns the cloned material
  82752. */
  82753. clone(name: string): SkyMaterial;
  82754. /**
  82755. * Serializes this material in a JSON representation
  82756. * @returns the serialized material object
  82757. */
  82758. serialize(): any;
  82759. /**
  82760. * Gets the current class name of the material e.g. "SkyMaterial"
  82761. * Mainly use in serialization.
  82762. * @returns the class name
  82763. */
  82764. getClassName(): string;
  82765. /**
  82766. * Creates a sky material from parsed material data
  82767. * @param source defines the JSON representation of the material
  82768. * @param scene defines the hosting scene
  82769. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  82770. * @returns a new sky material
  82771. */
  82772. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  82773. }
  82774. }
  82775. declare module BABYLON {
  82776. /** @hidden */
  82777. export var terrainPixelShader: {
  82778. name: string;
  82779. shader: string;
  82780. };
  82781. }
  82782. declare module BABYLON {
  82783. /** @hidden */
  82784. export var terrainVertexShader: {
  82785. name: string;
  82786. shader: string;
  82787. };
  82788. }
  82789. declare module BABYLON {
  82790. export class TerrainMaterial extends BABYLON.PushMaterial {
  82791. private _mixTexture;
  82792. mixTexture: BABYLON.BaseTexture;
  82793. private _diffuseTexture1;
  82794. diffuseTexture1: BABYLON.Texture;
  82795. private _diffuseTexture2;
  82796. diffuseTexture2: BABYLON.Texture;
  82797. private _diffuseTexture3;
  82798. diffuseTexture3: BABYLON.Texture;
  82799. private _bumpTexture1;
  82800. bumpTexture1: BABYLON.Texture;
  82801. private _bumpTexture2;
  82802. bumpTexture2: BABYLON.Texture;
  82803. private _bumpTexture3;
  82804. bumpTexture3: BABYLON.Texture;
  82805. diffuseColor: BABYLON.Color3;
  82806. specularColor: BABYLON.Color3;
  82807. specularPower: number;
  82808. private _disableLighting;
  82809. disableLighting: boolean;
  82810. private _maxSimultaneousLights;
  82811. maxSimultaneousLights: number;
  82812. constructor(name: string, scene: BABYLON.Scene);
  82813. needAlphaBlending(): boolean;
  82814. needAlphaTesting(): boolean;
  82815. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82816. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82817. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82818. getAnimatables(): BABYLON.IAnimatable[];
  82819. getActiveTextures(): BABYLON.BaseTexture[];
  82820. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82821. dispose(forceDisposeEffect?: boolean): void;
  82822. clone(name: string): TerrainMaterial;
  82823. serialize(): any;
  82824. getClassName(): string;
  82825. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  82826. }
  82827. }
  82828. declare module BABYLON {
  82829. /** @hidden */
  82830. export var triplanarPixelShader: {
  82831. name: string;
  82832. shader: string;
  82833. };
  82834. }
  82835. declare module BABYLON {
  82836. /** @hidden */
  82837. export var triplanarVertexShader: {
  82838. name: string;
  82839. shader: string;
  82840. };
  82841. }
  82842. declare module BABYLON {
  82843. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  82844. mixTexture: BABYLON.BaseTexture;
  82845. private _diffuseTextureX;
  82846. diffuseTextureX: BABYLON.BaseTexture;
  82847. private _diffuseTextureY;
  82848. diffuseTextureY: BABYLON.BaseTexture;
  82849. private _diffuseTextureZ;
  82850. diffuseTextureZ: BABYLON.BaseTexture;
  82851. private _normalTextureX;
  82852. normalTextureX: BABYLON.BaseTexture;
  82853. private _normalTextureY;
  82854. normalTextureY: BABYLON.BaseTexture;
  82855. private _normalTextureZ;
  82856. normalTextureZ: BABYLON.BaseTexture;
  82857. tileSize: number;
  82858. diffuseColor: BABYLON.Color3;
  82859. specularColor: BABYLON.Color3;
  82860. specularPower: number;
  82861. private _disableLighting;
  82862. disableLighting: boolean;
  82863. private _maxSimultaneousLights;
  82864. maxSimultaneousLights: number;
  82865. constructor(name: string, scene: BABYLON.Scene);
  82866. needAlphaBlending(): boolean;
  82867. needAlphaTesting(): boolean;
  82868. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82869. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82870. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82871. getAnimatables(): BABYLON.IAnimatable[];
  82872. getActiveTextures(): BABYLON.BaseTexture[];
  82873. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82874. dispose(forceDisposeEffect?: boolean): void;
  82875. clone(name: string): TriPlanarMaterial;
  82876. serialize(): any;
  82877. getClassName(): string;
  82878. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  82879. }
  82880. }
  82881. declare module BABYLON {
  82882. /** @hidden */
  82883. export var waterPixelShader: {
  82884. name: string;
  82885. shader: string;
  82886. };
  82887. }
  82888. declare module BABYLON {
  82889. /** @hidden */
  82890. export var waterVertexShader: {
  82891. name: string;
  82892. shader: string;
  82893. };
  82894. }
  82895. declare module BABYLON {
  82896. export class WaterMaterial extends BABYLON.PushMaterial {
  82897. renderTargetSize: BABYLON.Vector2;
  82898. private _bumpTexture;
  82899. bumpTexture: BABYLON.BaseTexture;
  82900. diffuseColor: BABYLON.Color3;
  82901. specularColor: BABYLON.Color3;
  82902. specularPower: number;
  82903. private _disableLighting;
  82904. disableLighting: boolean;
  82905. private _maxSimultaneousLights;
  82906. maxSimultaneousLights: number;
  82907. /**
  82908. * @param {number}: Represents the wind force
  82909. */
  82910. windForce: number;
  82911. /**
  82912. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  82913. */
  82914. windDirection: BABYLON.Vector2;
  82915. /**
  82916. * @param {number}: Wave height, represents the height of the waves
  82917. */
  82918. waveHeight: number;
  82919. /**
  82920. * @param {number}: Bump height, represents the bump height related to the bump map
  82921. */
  82922. bumpHeight: number;
  82923. /**
  82924. * @param {boolean}: Add a smaller moving bump to less steady waves.
  82925. */
  82926. private _bumpSuperimpose;
  82927. bumpSuperimpose: boolean;
  82928. /**
  82929. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  82930. */
  82931. private _fresnelSeparate;
  82932. fresnelSeparate: boolean;
  82933. /**
  82934. * @param {boolean}: bump Waves modify the reflection.
  82935. */
  82936. private _bumpAffectsReflection;
  82937. bumpAffectsReflection: boolean;
  82938. /**
  82939. * @param {number}: The water color blended with the refraction (near)
  82940. */
  82941. waterColor: BABYLON.Color3;
  82942. /**
  82943. * @param {number}: The blend factor related to the water color
  82944. */
  82945. colorBlendFactor: number;
  82946. /**
  82947. * @param {number}: The water color blended with the reflection (far)
  82948. */
  82949. waterColor2: BABYLON.Color3;
  82950. /**
  82951. * @param {number}: The blend factor related to the water color (reflection, far)
  82952. */
  82953. colorBlendFactor2: number;
  82954. /**
  82955. * @param {number}: Represents the maximum length of a wave
  82956. */
  82957. waveLength: number;
  82958. /**
  82959. * @param {number}: Defines the waves speed
  82960. */
  82961. waveSpeed: number;
  82962. /**
  82963. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  82964. * will avoid calculating useless pixels in the pixel shader of the water material.
  82965. */
  82966. disableClipPlane: boolean;
  82967. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  82968. private _mesh;
  82969. private _refractionRTT;
  82970. private _reflectionRTT;
  82971. private _reflectionTransform;
  82972. private _lastTime;
  82973. private _lastDeltaTime;
  82974. private _useLogarithmicDepth;
  82975. private _waitingRenderList;
  82976. private _imageProcessingConfiguration;
  82977. private _imageProcessingObserver;
  82978. /**
  82979. * Gets a boolean indicating that current material needs to register RTT
  82980. */
  82981. get hasRenderTargetTextures(): boolean;
  82982. /**
  82983. * Constructor
  82984. */
  82985. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  82986. get useLogarithmicDepth(): boolean;
  82987. set useLogarithmicDepth(value: boolean);
  82988. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  82989. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  82990. addToRenderList(node: any): void;
  82991. enableRenderTargets(enable: boolean): void;
  82992. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  82993. get renderTargetsEnabled(): boolean;
  82994. needAlphaBlending(): boolean;
  82995. needAlphaTesting(): boolean;
  82996. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82997. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82998. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82999. private _createRenderTargets;
  83000. getAnimatables(): BABYLON.IAnimatable[];
  83001. getActiveTextures(): BABYLON.BaseTexture[];
  83002. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83003. dispose(forceDisposeEffect?: boolean): void;
  83004. clone(name: string): WaterMaterial;
  83005. serialize(): any;
  83006. getClassName(): string;
  83007. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  83008. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  83009. }
  83010. }
  83011. declare module BABYLON {
  83012. /** @hidden */
  83013. export var asciiartPixelShader: {
  83014. name: string;
  83015. shader: string;
  83016. };
  83017. }
  83018. declare module BABYLON {
  83019. /**
  83020. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  83021. *
  83022. * It basically takes care rendering the font front the given font size to a texture.
  83023. * This is used later on in the postprocess.
  83024. */
  83025. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  83026. private _font;
  83027. private _text;
  83028. private _charSize;
  83029. /**
  83030. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  83031. */
  83032. get charSize(): number;
  83033. /**
  83034. * Create a new instance of the Ascii Art FontTexture class
  83035. * @param name the name of the texture
  83036. * @param font the font to use, use the W3C CSS notation
  83037. * @param text the caracter set to use in the rendering.
  83038. * @param scene the scene that owns the texture
  83039. */
  83040. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  83041. /**
  83042. * Gets the max char width of a font.
  83043. * @param font the font to use, use the W3C CSS notation
  83044. * @return the max char width
  83045. */
  83046. private getFontWidth;
  83047. /**
  83048. * Gets the max char height of a font.
  83049. * @param font the font to use, use the W3C CSS notation
  83050. * @return the max char height
  83051. */
  83052. private getFontHeight;
  83053. /**
  83054. * Clones the current AsciiArtTexture.
  83055. * @return the clone of the texture.
  83056. */
  83057. clone(): AsciiArtFontTexture;
  83058. /**
  83059. * Parses a json object representing the texture and returns an instance of it.
  83060. * @param source the source JSON representation
  83061. * @param scene the scene to create the texture for
  83062. * @return the parsed texture
  83063. */
  83064. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  83065. }
  83066. /**
  83067. * Option available in the Ascii Art Post Process.
  83068. */
  83069. export interface IAsciiArtPostProcessOptions {
  83070. /**
  83071. * The font to use following the w3c font definition.
  83072. */
  83073. font?: string;
  83074. /**
  83075. * The character set to use in the postprocess.
  83076. */
  83077. characterSet?: string;
  83078. /**
  83079. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  83080. * This number is defined between 0 and 1;
  83081. */
  83082. mixToTile?: number;
  83083. /**
  83084. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  83085. * This number is defined between 0 and 1;
  83086. */
  83087. mixToNormal?: number;
  83088. }
  83089. /**
  83090. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  83091. *
  83092. * Simmply add it to your scene and let the nerd that lives in you have fun.
  83093. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  83094. */
  83095. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  83096. /**
  83097. * The font texture used to render the char in the post process.
  83098. */
  83099. private _asciiArtFontTexture;
  83100. /**
  83101. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  83102. * This number is defined between 0 and 1;
  83103. */
  83104. mixToTile: number;
  83105. /**
  83106. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  83107. * This number is defined between 0 and 1;
  83108. */
  83109. mixToNormal: number;
  83110. /**
  83111. * Instantiates a new Ascii Art Post Process.
  83112. * @param name the name to give to the postprocess
  83113. * @camera the camera to apply the post process to.
  83114. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  83115. */
  83116. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  83117. }
  83118. }
  83119. declare module BABYLON {
  83120. /** @hidden */
  83121. export var digitalrainPixelShader: {
  83122. name: string;
  83123. shader: string;
  83124. };
  83125. }
  83126. declare module BABYLON {
  83127. /**
  83128. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  83129. *
  83130. * It basically takes care rendering the font front the given font size to a texture.
  83131. * This is used later on in the postprocess.
  83132. */
  83133. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  83134. private _font;
  83135. private _text;
  83136. private _charSize;
  83137. /**
  83138. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  83139. */
  83140. get charSize(): number;
  83141. /**
  83142. * Create a new instance of the Digital Rain FontTexture class
  83143. * @param name the name of the texture
  83144. * @param font the font to use, use the W3C CSS notation
  83145. * @param text the caracter set to use in the rendering.
  83146. * @param scene the scene that owns the texture
  83147. */
  83148. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  83149. /**
  83150. * Gets the max char width of a font.
  83151. * @param font the font to use, use the W3C CSS notation
  83152. * @return the max char width
  83153. */
  83154. private getFontWidth;
  83155. /**
  83156. * Gets the max char height of a font.
  83157. * @param font the font to use, use the W3C CSS notation
  83158. * @return the max char height
  83159. */
  83160. private getFontHeight;
  83161. /**
  83162. * Clones the current DigitalRainFontTexture.
  83163. * @return the clone of the texture.
  83164. */
  83165. clone(): DigitalRainFontTexture;
  83166. /**
  83167. * Parses a json object representing the texture and returns an instance of it.
  83168. * @param source the source JSON representation
  83169. * @param scene the scene to create the texture for
  83170. * @return the parsed texture
  83171. */
  83172. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  83173. }
  83174. /**
  83175. * Option available in the Digital Rain Post Process.
  83176. */
  83177. export interface IDigitalRainPostProcessOptions {
  83178. /**
  83179. * The font to use following the w3c font definition.
  83180. */
  83181. font?: string;
  83182. /**
  83183. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  83184. * This number is defined between 0 and 1;
  83185. */
  83186. mixToTile?: number;
  83187. /**
  83188. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  83189. * This number is defined between 0 and 1;
  83190. */
  83191. mixToNormal?: number;
  83192. }
  83193. /**
  83194. * DigitalRainPostProcess helps rendering everithing in digital rain.
  83195. *
  83196. * Simmply add it to your scene and let the nerd that lives in you have fun.
  83197. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  83198. */
  83199. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  83200. /**
  83201. * The font texture used to render the char in the post process.
  83202. */
  83203. private _digitalRainFontTexture;
  83204. /**
  83205. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  83206. * This number is defined between 0 and 1;
  83207. */
  83208. mixToTile: number;
  83209. /**
  83210. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  83211. * This number is defined between 0 and 1;
  83212. */
  83213. mixToNormal: number;
  83214. /**
  83215. * Instantiates a new Digital Rain Post Process.
  83216. * @param name the name to give to the postprocess
  83217. * @camera the camera to apply the post process to.
  83218. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  83219. */
  83220. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  83221. }
  83222. }
  83223. declare module BABYLON {
  83224. /** @hidden */
  83225. export var brickProceduralTexturePixelShader: {
  83226. name: string;
  83227. shader: string;
  83228. };
  83229. }
  83230. declare module BABYLON {
  83231. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  83232. private _numberOfBricksHeight;
  83233. private _numberOfBricksWidth;
  83234. private _jointColor;
  83235. private _brickColor;
  83236. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83237. updateShaderUniforms(): void;
  83238. get numberOfBricksHeight(): number;
  83239. set numberOfBricksHeight(value: number);
  83240. get numberOfBricksWidth(): number;
  83241. set numberOfBricksWidth(value: number);
  83242. get jointColor(): BABYLON.Color3;
  83243. set jointColor(value: BABYLON.Color3);
  83244. get brickColor(): BABYLON.Color3;
  83245. set brickColor(value: BABYLON.Color3);
  83246. /**
  83247. * Serializes this brick procedural texture
  83248. * @returns a serialized brick procedural texture object
  83249. */
  83250. serialize(): any;
  83251. /**
  83252. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  83253. * @param parsedTexture defines parsed texture data
  83254. * @param scene defines the current scene
  83255. * @param rootUrl defines the root URL containing brick procedural texture information
  83256. * @returns a parsed Brick Procedural BABYLON.Texture
  83257. */
  83258. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  83259. }
  83260. }
  83261. declare module BABYLON {
  83262. /** @hidden */
  83263. export var cloudProceduralTexturePixelShader: {
  83264. name: string;
  83265. shader: string;
  83266. };
  83267. }
  83268. declare module BABYLON {
  83269. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  83270. private _skyColor;
  83271. private _cloudColor;
  83272. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83273. updateShaderUniforms(): void;
  83274. get skyColor(): BABYLON.Color4;
  83275. set skyColor(value: BABYLON.Color4);
  83276. get cloudColor(): BABYLON.Color4;
  83277. set cloudColor(value: BABYLON.Color4);
  83278. /**
  83279. * Serializes this cloud procedural texture
  83280. * @returns a serialized cloud procedural texture object
  83281. */
  83282. serialize(): any;
  83283. /**
  83284. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  83285. * @param parsedTexture defines parsed texture data
  83286. * @param scene defines the current scene
  83287. * @param rootUrl defines the root URL containing cloud procedural texture information
  83288. * @returns a parsed Cloud Procedural BABYLON.Texture
  83289. */
  83290. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  83291. }
  83292. }
  83293. declare module BABYLON {
  83294. /** @hidden */
  83295. export var fireProceduralTexturePixelShader: {
  83296. name: string;
  83297. shader: string;
  83298. };
  83299. }
  83300. declare module BABYLON {
  83301. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  83302. private _time;
  83303. private _speed;
  83304. private _autoGenerateTime;
  83305. private _fireColors;
  83306. private _alphaThreshold;
  83307. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83308. updateShaderUniforms(): void;
  83309. render(useCameraPostProcess?: boolean): void;
  83310. static get PurpleFireColors(): BABYLON.Color3[];
  83311. static get GreenFireColors(): BABYLON.Color3[];
  83312. static get RedFireColors(): BABYLON.Color3[];
  83313. static get BlueFireColors(): BABYLON.Color3[];
  83314. get autoGenerateTime(): boolean;
  83315. set autoGenerateTime(value: boolean);
  83316. get fireColors(): BABYLON.Color3[];
  83317. set fireColors(value: BABYLON.Color3[]);
  83318. get time(): number;
  83319. set time(value: number);
  83320. get speed(): BABYLON.Vector2;
  83321. set speed(value: BABYLON.Vector2);
  83322. get alphaThreshold(): number;
  83323. set alphaThreshold(value: number);
  83324. /**
  83325. * Serializes this fire procedural texture
  83326. * @returns a serialized fire procedural texture object
  83327. */
  83328. serialize(): any;
  83329. /**
  83330. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  83331. * @param parsedTexture defines parsed texture data
  83332. * @param scene defines the current scene
  83333. * @param rootUrl defines the root URL containing fire procedural texture information
  83334. * @returns a parsed Fire Procedural BABYLON.Texture
  83335. */
  83336. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  83337. }
  83338. }
  83339. declare module BABYLON {
  83340. /** @hidden */
  83341. export var grassProceduralTexturePixelShader: {
  83342. name: string;
  83343. shader: string;
  83344. };
  83345. }
  83346. declare module BABYLON {
  83347. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  83348. private _grassColors;
  83349. private _groundColor;
  83350. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83351. updateShaderUniforms(): void;
  83352. get grassColors(): BABYLON.Color3[];
  83353. set grassColors(value: BABYLON.Color3[]);
  83354. get groundColor(): BABYLON.Color3;
  83355. set groundColor(value: BABYLON.Color3);
  83356. /**
  83357. * Serializes this grass procedural texture
  83358. * @returns a serialized grass procedural texture object
  83359. */
  83360. serialize(): any;
  83361. /**
  83362. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  83363. * @param parsedTexture defines parsed texture data
  83364. * @param scene defines the current scene
  83365. * @param rootUrl defines the root URL containing grass procedural texture information
  83366. * @returns a parsed Grass Procedural BABYLON.Texture
  83367. */
  83368. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  83369. }
  83370. }
  83371. declare module BABYLON {
  83372. /** @hidden */
  83373. export var marbleProceduralTexturePixelShader: {
  83374. name: string;
  83375. shader: string;
  83376. };
  83377. }
  83378. declare module BABYLON {
  83379. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  83380. private _numberOfTilesHeight;
  83381. private _numberOfTilesWidth;
  83382. private _amplitude;
  83383. private _jointColor;
  83384. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83385. updateShaderUniforms(): void;
  83386. get numberOfTilesHeight(): number;
  83387. set numberOfTilesHeight(value: number);
  83388. get amplitude(): number;
  83389. set amplitude(value: number);
  83390. get numberOfTilesWidth(): number;
  83391. set numberOfTilesWidth(value: number);
  83392. get jointColor(): BABYLON.Color3;
  83393. set jointColor(value: BABYLON.Color3);
  83394. /**
  83395. * Serializes this marble procedural texture
  83396. * @returns a serialized marble procedural texture object
  83397. */
  83398. serialize(): any;
  83399. /**
  83400. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  83401. * @param parsedTexture defines parsed texture data
  83402. * @param scene defines the current scene
  83403. * @param rootUrl defines the root URL containing marble procedural texture information
  83404. * @returns a parsed Marble Procedural BABYLON.Texture
  83405. */
  83406. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  83407. }
  83408. }
  83409. declare module BABYLON {
  83410. /** @hidden */
  83411. export var normalMapProceduralTexturePixelShader: {
  83412. name: string;
  83413. shader: string;
  83414. };
  83415. }
  83416. declare module BABYLON {
  83417. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  83418. private _baseTexture;
  83419. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83420. updateShaderUniforms(): void;
  83421. render(useCameraPostProcess?: boolean): void;
  83422. resize(size: any, generateMipMaps: any): void;
  83423. get baseTexture(): BABYLON.Texture;
  83424. set baseTexture(texture: BABYLON.Texture);
  83425. /**
  83426. * Serializes this normal map procedural texture
  83427. * @returns a serialized normal map procedural texture object
  83428. */
  83429. serialize(): any;
  83430. /**
  83431. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  83432. * @param parsedTexture defines parsed texture data
  83433. * @param scene defines the current scene
  83434. * @param rootUrl defines the root URL containing normal map procedural texture information
  83435. * @returns a parsed Normal Map Procedural BABYLON.Texture
  83436. */
  83437. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  83438. }
  83439. }
  83440. declare module BABYLON {
  83441. /** @hidden */
  83442. export var perlinNoiseProceduralTexturePixelShader: {
  83443. name: string;
  83444. shader: string;
  83445. };
  83446. }
  83447. declare module BABYLON {
  83448. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  83449. time: number;
  83450. timeScale: number;
  83451. translationSpeed: number;
  83452. private _currentTranslation;
  83453. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83454. updateShaderUniforms(): void;
  83455. render(useCameraPostProcess?: boolean): void;
  83456. resize(size: any, generateMipMaps: any): void;
  83457. /**
  83458. * Serializes this perlin noise procedural texture
  83459. * @returns a serialized perlin noise procedural texture object
  83460. */
  83461. serialize(): any;
  83462. /**
  83463. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  83464. * @param parsedTexture defines parsed texture data
  83465. * @param scene defines the current scene
  83466. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  83467. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  83468. */
  83469. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  83470. }
  83471. }
  83472. declare module BABYLON {
  83473. /** @hidden */
  83474. export var roadProceduralTexturePixelShader: {
  83475. name: string;
  83476. shader: string;
  83477. };
  83478. }
  83479. declare module BABYLON {
  83480. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  83481. private _roadColor;
  83482. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83483. updateShaderUniforms(): void;
  83484. get roadColor(): BABYLON.Color3;
  83485. set roadColor(value: BABYLON.Color3);
  83486. /**
  83487. * Serializes this road procedural texture
  83488. * @returns a serialized road procedural texture object
  83489. */
  83490. serialize(): any;
  83491. /**
  83492. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  83493. * @param parsedTexture defines parsed texture data
  83494. * @param scene defines the current scene
  83495. * @param rootUrl defines the root URL containing road procedural texture information
  83496. * @returns a parsed Road Procedural BABYLON.Texture
  83497. */
  83498. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  83499. }
  83500. }
  83501. declare module BABYLON {
  83502. /** @hidden */
  83503. export var starfieldProceduralTexturePixelShader: {
  83504. name: string;
  83505. shader: string;
  83506. };
  83507. }
  83508. declare module BABYLON {
  83509. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  83510. private _time;
  83511. private _alpha;
  83512. private _beta;
  83513. private _zoom;
  83514. private _formuparam;
  83515. private _stepsize;
  83516. private _tile;
  83517. private _brightness;
  83518. private _darkmatter;
  83519. private _distfading;
  83520. private _saturation;
  83521. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83522. updateShaderUniforms(): void;
  83523. get time(): number;
  83524. set time(value: number);
  83525. get alpha(): number;
  83526. set alpha(value: number);
  83527. get beta(): number;
  83528. set beta(value: number);
  83529. get formuparam(): number;
  83530. set formuparam(value: number);
  83531. get stepsize(): number;
  83532. set stepsize(value: number);
  83533. get zoom(): number;
  83534. set zoom(value: number);
  83535. get tile(): number;
  83536. set tile(value: number);
  83537. get brightness(): number;
  83538. set brightness(value: number);
  83539. get darkmatter(): number;
  83540. set darkmatter(value: number);
  83541. get distfading(): number;
  83542. set distfading(value: number);
  83543. get saturation(): number;
  83544. set saturation(value: number);
  83545. /**
  83546. * Serializes this starfield procedural texture
  83547. * @returns a serialized starfield procedural texture object
  83548. */
  83549. serialize(): any;
  83550. /**
  83551. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  83552. * @param parsedTexture defines parsed texture data
  83553. * @param scene defines the current scene
  83554. * @param rootUrl defines the root URL containing startfield procedural texture information
  83555. * @returns a parsed Starfield Procedural BABYLON.Texture
  83556. */
  83557. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  83558. }
  83559. }
  83560. declare module BABYLON {
  83561. /** @hidden */
  83562. export var woodProceduralTexturePixelShader: {
  83563. name: string;
  83564. shader: string;
  83565. };
  83566. }
  83567. declare module BABYLON {
  83568. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  83569. private _ampScale;
  83570. private _woodColor;
  83571. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83572. updateShaderUniforms(): void;
  83573. get ampScale(): number;
  83574. set ampScale(value: number);
  83575. get woodColor(): BABYLON.Color3;
  83576. set woodColor(value: BABYLON.Color3);
  83577. /**
  83578. * Serializes this wood procedural texture
  83579. * @returns a serialized wood procedural texture object
  83580. */
  83581. serialize(): any;
  83582. /**
  83583. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  83584. * @param parsedTexture defines parsed texture data
  83585. * @param scene defines the current scene
  83586. * @param rootUrl defines the root URL containing wood procedural texture information
  83587. * @returns a parsed Wood Procedural BABYLON.Texture
  83588. */
  83589. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  83590. }
  83591. }